Monday, January 12, 2009

Hello Blink!

Everybody seems to be messing with Arduino lately. So today was my chance to give it a go. Jimmie Rodgers of Willoughby and Baltic helped me set up the software on my laptop at Noise Night. It was incredibly easy, and he helped me to understand that the IDE for the 'regular Arduinos' is different for that used on the Minty POV and Brain Machine.

Stephanie, one of my Programming students had a piece of code running on her laptop and wanted to test it with four LEDs. We set up a breadboard with the LEDs, and she got her program to run. She had it going Cylon style, where the light would pass from side to side. After she left, I noticed the breadboard sitting on the table, still hooked up to the arduino, so I figured I would give it a whirl. I plugged it into the USB port, fired up the IDE and saw her program run.

Then I decided I wanted to mess with it on my own, so I did a search for "Hello World Arduino" Hello World is usually the simplest program you can run in a computer language. I wanted simple, so I could understand what it was doing. I found the code, which is also in the Help Menu under something or another, but I couldn't find it easily. I recalled that Jimmie had told me that Blink is the first program you want to run.

I copied the code and pasted it into the script window. Then I had to figure out how to get it to the board. I hit the Compile window, which looks like a play button, and saw that it compiled. I tried changing a few things, and broke it.

Earlier, Stephanie had some basic problems as well, such as not spelling the variable names exactly the same throughout the code. Hand typed code is case sensitive, so it's important not to mess with it too much. When we were debugging her code, I put some comment marks ( // ) in front of the lines that were throwing the errors. Eventually, we figured out that the problem was capitalization.

After compiling, I had to save the file, and then download it to the board. I was very happy when I saw that one LED blink. After about a half a minute, I got bored, and started messing with the code. I tried changing the duration of the blink and pause, and then I made each of the four LEDs do thier blinky thing.

So now I have made an Arduino blink. There is so much more that can be done, but it all has to start someplace. This step for me has been a major block. For some reason, I haven't been able to get it going. But now it is going. Hopefully others may find this moment useful. If you do, let me know in the comments.

Labels: , , , , ,