When I got my Arduino, I also got a Proto Shield from Adafruit. This is an extremely handy shield to get for quickly mucking around with stuff. It’s especially handy for people like me who suck at soldering. One problem: it’s a kit and requires that you solder it together. And of course my soldering skillz bit me in the ass. While playing around with the board and some code, I simply couldn’t get my LED to light the green pin. I spent an hour or so debugging my code and wiring, only to find out that I had a poor soldering joint on one of my pins! Suck. After resoldering that one pin, I was back in business.
In the last post, I mentioned the “protocol” that I want to use to send color info to the Arduino and make the RGB LED light purty colors. My goal was to rewrite fade.pde to take in serial input, parse out the color info, and then build a state machine so that the Arduino would be the right color and either throb or be solid. After a few revisions, here is what I ended up with for my throb() method:
I set up the following #defines for states:
And finally, the FSM:
I’m pretty happy with it. And it works great! Finally. You see, I had a major problem where the data coming in off the wire was getting corrupted. Note that I’m testing this through the Arduino IDE’s serial monitor. Although the initial “#” was properly detected, I would always get complete garbage for the subsequent bytes in the buffer. (BTW, this explains the stuff within the #ifdef _DEBUG” block.) After adding a delay(10) after the Serial.read(), it magically started working like a champ. The kick in the ass is that I couldn’t find another example of anyone requiring this. Could this be a problem with my USB port? Is anyone else seeing this behavior.
But there it is – quicker progress than I expected. The Arduino is now in a state where I can just write an arbitrary app to bitbang a color value and make the LED light up. I’ll try to post a video when I get a chance. I’ll also try to put the code up on codeplex or the arduino.cc site. Next steps: build a small WPF app to sniff the OCS status change event (I’m probably going to start off with the example provided by the Office Communicator SDK Wrapper and go from there).