Friday, September 29, 2006
lab: week 3, Analog Input w/Arduino
When i first programmed the arduino for this, I made the mistake of not dividing the value that i read off the analog-in pin (the one that the photocell is connected to), which resulted in my LEDs jumping up and down, from on to off. This is because I can only output a maximum of 8 bits, or a value of 255, although 10 bits, or a max value of 1023 can be read as input. In order to adjust this, i divided the value read off my analog-in pin by 4.
The jumping from light to dark happens when the output value being sent to the LED goes over 255 (max brightness, and the max value the LED can accept). For every value over 255, the LED will roll back to 0 (off) back up to 255 (fully on). So a value of 256 equals 0, 257 equals 1, 512 equals 0, and so on and so forth.