DIY Light Show
I've decided to try posting the first part as a separate P2PU Challenge page:
http://p2pu.org/en/groups/2-writing-html-by-hand-2/
Bonus for this group:
The examples above used digitalWrite( pin, HIGH ) or digitalWrite( pin, LOW ) to turn a light completely on or completely off, respectively.
- Connect your LED to a pin with a tilde mark (looks like ~). For example, pin 9. These pins can be used for digital (completely on/off signal) or analog (variable signal).
- Revise your code to use pin 9. Don't forget to update the pin number in the line pinMode(pin, OUTPUT);
- Instead of digitalWrite(pin, HIGH);, use analogWrite(pin, value); to set the light between completely on and off. In this case, instead of HIGH or LOW, you must use a number value between 0 and 255. Lower values will fail to turn on the LED at all. Why is that?