Changes

Week 3 Lab

567 bytes added, 18:54, 14 April 2009
LED Dimming
*File->Sketchbook->Examples->Analog->Fading
The crux of this sketch is the <code>analogWrite() </code> function.
*lightsNOTE: The function <code>analogWrite()</code> only works on some digital output pins. Look up the help for the function, fadingit will tell you which pins work: Digital pins 3,5,6,9,10, and 11.
<youtube v="62gWVWCyw_w" loop="true"/>
* Get this working. Then...
* Q: Drive this dimming example with the light sensor from before.
** use <code>analogRead()</code> to get the value from the sensor, like you did before, then use <code>analogWrite()</code> to output the value to the LED. NOTE: <code>analogRead()</code> will return values from 0-1023, and <code>analogWrite()</code> writes values from 0 to 255, so you will need to divide your read value by 4 to get the output value. Or you could use <code>map()</code>
* Q: Does yours turn on when it is light, or does it turn off? Switch this to give it the opposite behavior, in either hardware or software. You could do either!