Upcoming shows
No shows booked at the moment.
Categories
Archives
Internet show tonight
Good news everyone! I’m playing a solo concert on the Internet this evening. You are invited to aim a web browser at a URL and watch video of myself playing a few songs old and new, as part of a concert series called Plastic Jet Airline.
The show starts at 7pm Pacific Standard Time.
Here are some links:
Posted in Music, Sun Tunnels, The graze
Leave a comment
Arduino Morse – pt. 2 – only Morseo
In my last post I wrote about a Morse code project I wrote for Arduino. I have a few additions to make on that subject..
Firstly, I rewrote the main bits of this code as a library, and renamed it Morseo (pronounced “more so.” It’s like a pun). It’s on GitHub now as well.. I’ll probably delete the old project.
In the course of turning it into a library I learned a few things.. primarily, how to turn it into a library. Arduino’s guide to making a library uses as an example a program that flashes, wait for it, Morse code. That was a fun coincidence, though I would note their example only flashes “SOS,” and mine does more than that. Still, kind of annoying. I’m under no impression that this project is unique, but I’d prefer it not to resemble the boilerplate.
Secondly, Arduino is coded in C++, not so much C, as I asserted in my last post. Duly noted.
Finally, Arduino includes a serial library for writing messages back to the PC host you’ve plugged it into via USB. Somehow I neglected to know this when I developed Morseo, which meant I had exactly one LED to debug with. This made debugging a lot of fun — seriously, it was a fun challenge — but more tedious than necessary. Next time, I’ll use the serial library to send myself messages, and I would hope anyone approaching Arduino programming for the first time knows this at the beginning.
Up next: I have a wifi adapter now, I think a good next step would be to flash statements from a Twitter account or something.
Posted in Programming, Projects
Leave a comment
Arduino Morse
For my first Arduino project (and my first project of any sort on Github) I chose something that could manipulate Arduino’s on-board LED — as per the “Blink” sample project, since it would require no additional hardware — but what can you do with a single light? Morse code, naturally.
Arduinos are generally programmed in C, and I’m a C# developer mainly, so this would be a fun evenings and weekends project. I wanted to define a string of text and have the LED blink that message out in Morse. The message would be hard-coded in the program itself, though if the input part of it were to ever become more dynamic (like from reading a Tweet, or something) then the rest should be mostly reusable.
The first version of the program didn’t take very long to write, but it wasn’t very elegant. I wanted to separate some of its various concerns into separate functions, so I tried again. Here I ran into some peculiarities with how C handles strings that was taking a lot of time to figure out. Other things came up and I put the project aside for a while.
I picked it up again finally a couple of weeks ago and finished it off. The string issues I had that weren’t immediately obvious included:
- You can use char* to declare a string variable and initialize it later, but once initialized it’s read-only. You can’t treat it like a regular array and alter individual chars.
- If you declare a char* with the intent to initialize it in another function, you need to pass it as a char**.
- The aforementioned char pointer issues became moot when I found what I really wanted was to declare a string variable in one function, initialize it in another, and also manipulate its char elements. In C# you don’t have to think very hard to do this, you can do most anything you want to a string and it “just works.” In my case I found I had to use char arrays, and to treat these variables as buffers.
I’d seen this pattern often enough before, of declaring a buffer of some length and passing it into a function by reference, usually when doing some sort of I/O to/from a socket or file. I don’t know if that was the only option I had to work with, but in the end it did what I wanted.
For what it does, which is next to nothing, the program might be a bit overengineered. The main point of the project though was to learn something new and have fun with it. A next step along those lines might be to make it into a Morse library with some abstractions around possible input and output options, just to learn how C libraries work. I don’t know. I know other Morse programs for Arduino exist and I’ve purposefully ignored them so I can play this out for what its worth as a learning exercise. If anyone wants to work with this code and send me suggestions/corrections, definitely please do that.
Posted in Programming, Uncategorized
1 Comment



