Week 3: Times Square and Multiple Inputs

This week pushed me to complete multiple tutorial portions. Specifically, the first new piece of equipment was the RGB led. I have used this device for previous projects, but my use was limited to a single color. At first I copied the example code for sweeping through various colors and then I tried to recreate this code from scratch to test my understanding of each part of the code.

The code can be downloaded here.




To be honest this was the first time that I really felt challenged by the coding portion of the arduino. The past two weeks I was able to breeze through the code as it was very similar to the robotics coding that I teach. This week took a couple of steps up, introducing for loops, void functions, and arrays all at once. I anxiously await to read how my colleagues approached this week.


The first major challenge was to combine the various circuits together. The multiple leds activity reminded me of watching the New Years ball drop at Times Square. I combined the countdown with a function that randomized the colors of each of the RGB, producing a stobelight effect.

The code can be downloaded here.




The final 'extra' challenge prompted me to control the RGB led using three different inputs. This has been the largest project I have done so far. I started by diagraming out how I wanted to connect all of my devices, see the picture below:


I tried to label every digital and analog port so that the wiring would be easier. After I started I realized that my thermoresistor was already a three pronged device, so I redrew it to resemble the potentiometer drawing.

After I had connected all of the wires and I began program I ran into a new problem, I had no idea what sorts of values the thermoresistor and photoresistor would produce. From last week's activities I knew the potentiometer ranged from 0-1023. In order to find out the ranges I went back to the debugging tools I found last week. See the video below:



I kept their ranges on the top corner of my setup page. I found that in my room the photoresistor took on values near zero when in darkness, the ambient room light produces a value near 30 and a flashlight was able to increase it all the way to 300.

The thermoresistor was a bit more challenging. I conducted the same process as with the photoresistor, identifying the values via the debugger window. I found that at room temperature the value was near 155, while after I covered the thermoresistor with my hand it increased to near 165. I plugged these values in, and after a short dinner break, I came back and tested the code. To my surprise the Red LED (connected to the thermoresistor) was very sporatic. I re-examined the values via the debugger and found that my room had dropped to 148, with my hand only bringing the values up to 160. I was a little surprised to see such a large swing in resting values over such a short period of time. (This was the reason for the crossed out sections).

My final coding fix was to create two variables for the cold value and warm value of the thermoresistor. I put them at the top of my code so that they were easily accessible. Now if I were to run this program again I would first measure the current values from the room's temperatures, change the variables, and then the code would work.

The code can be downloaded here.



Comments