Sunday, February 2, 2014

Circuit 4

At first I thought this circuit was redundant, but as soon as I began to wire it up I realized that the complexity of the wiring forced me into thinking more deliberately about placement and "conventions" like common orientation of the LEDs and routing of the wires. When it came to code, the combination of arrays, incremented variables and functions is starting to make the code much more powerful. Dividing code into functions also facilitates troubleshooting, allowing one to isolate individual routines.

First modification: Running all five functions with a slight delay between each, and repeating the random LED 8 times (slowed to so as to be noticeable) plus a delay at the end of the 5-function cycle. This manipulation was good exercise in syntax as I manipulated and combined pieces of the code to make them more complex.

Second modification" extending the idea of a random variable to randomize speed and which function is called using IF... ELSE IF. Also good practice in "handing" a parameter to a function! Unfortunately I spent several HOURS on this sketch and was unable to make it work the way I want... troubleshooting steps include output of the random variable to the Serial Monitor, isolating sections of the sketch, and more. There is something wrong with the if... else command, but I can;t figure out WHAT!

Circuit 4 video

No comments:

Post a Comment