Instructables

Step 4: Arduino Code

1. The Arduino code has three main sections: declaration, initialization and then an inifinite loop.
2. In the declaration section, set up global constant variables such as start and end bits for recieved signals and color declarations.
3. In the initialization section do following: set up contact by sending a start signal over the serial lines and set all the GPIO pins to be used to be in Digital Out mode so that they can drive the LEDS.
4. In the loop create two states: waiting for input and writing to the LEDS.
5. On the wait step, use delay(100) to make the Arduino board pause for 100 miliseconds
6. In the write phase, make the Arduino do the following:
a) Get the start flag, end flag, city(integer corresponding to a base pin) and color from the serial line and assert that the flags are correctly set.
b) Write a color to a specific city by first turning that city off and then using the color to turn on a combination of pins which correlate to an RGB color scheme from the base pin.

Our code for this step can be found at https://github.com/ianisborn/TTT/tree/master/sandbox
 
Remove these adsRemove these ads by Signing Up