Friday, October 9, 2009

Week Two Exercise 1

Exercise #1

First, i am setting up intergers for the led pin, the photo pin, and both values for them (ignore the lightBlink1-6 integers). Now, in the void setup, i am setting up the ledpin to outPut, and set up the serial, to later on print values. here comes the void loop where everythign happens constantly. i am setting photovalue so that every time it is called, it will read photoPin analog-ly which can range in values rather then just HIGH and LOW, (0 and 255) next we are setting lightValue to be photoValue divided by 4 because it dives i believe 1,020 into a scale between 0 to 255 in which it can read. Finally we analog-ly write ledPin to the value of photoValue, and then we print the outcome. (the delay of 1 is so that the computer is not reading it as fast, because there is no point for it to work that hard.)

No comments:

Post a Comment