User Tools

Site Tools


oak:tutorials:rgb-led

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
oak:tutorials:rgb-led [2016/03/23 21:41]
jwhendy created
oak:tutorials:rgb-led [2016/04/19 17:44] (current)
jwhendy fixed wrong pin number
Line 8: Line 8:
  
 ^Part ^Quantity ^Identification^ ^Part ^Quantity ^Identification^
-|Oak with soldered headers|1|| +|Oak with soldered headers| 1 | | 
-|Breadboard|1| |+|Breadboard| 1 | |
 |Jumper wires | 4 | | |Jumper wires | 4 | |
-|RGB LED|1|whitish LED with 4 leads, one longer than the others|+|RGB LED| 1 | whitish LED with 4 leads, one longer than the others | 
 +|Resistor, 220 ohm| 3 | Red-Red-Brown| 
 + 
 +**Note:** 220 ohms is a ballpark recommendation;​ acceptable values are between 100 - 1k ohms.
  
 ===== Concepts ===== ===== Concepts =====
Line 38: Line 41:
   * Connect one jumper wire from pins 6, 7, and 8 to each of the free ends of the resistor   * Connect one jumper wire from pins 6, 7, and 8 to each of the free ends of the resistor
  
 +Here is an example of a real world setup:
 +
 +[[http://​digistump.com/​wiki/​_media/​oak-wiring-rgb-led.jpg|{{http://​digistump.com/​wiki/​_media/​oak-wiring-rgb-led.jpg?​400}}]]
 ===== Code ===== ===== Code =====
  
Line 51: Line 57:
   pinMode(6, OUTPUT);   pinMode(6, OUTPUT);
   pinMode(7, OUTPUT);   pinMode(7, OUTPUT);
-  pinMode(7, OUTPUT);+  pinMode(8, OUTPUT);
  
 } }
Line 81: Line 87:
  
 You should see each color pulse, one at a time, each over the course of ~2 seconds. You should see each color pulse, one at a time, each over the course of ~2 seconds.
 +
 +[[http://​digistump.com/​wiki/​_media/​oak-rgb-led-cycle.gif|{{http://​digistump.com/​wiki/​_media/​oak-rgb-led-cycle.gif?​400}}]]
  
 === Code: fading through the rainbow === === Code: fading through the rainbow ===
Line 154: Line 162:
 We ramp up the red channel of the LED, and when it's halfway through (when ''​i = 500''​),​ the green channel begins ramping up. At ''​i = 1000'',​ the red channel is fully on, green is halfway to full on, and blue is just starting. They start and stop the process approximately half a second offset from each other, and once they'​re all at full brightness, the process reverses to bring them back down to off. We ramp up the red channel of the LED, and when it's halfway through (when ''​i = 500''​),​ the green channel begins ramping up. At ''​i = 1000'',​ the red channel is fully on, green is halfway to full on, and blue is just starting. They start and stop the process approximately half a second offset from each other, and once they'​re all at full brightness, the process reverses to bring them back down to off.
  
-Here's what you will see with the code above!+Here's what you will see with the code above! ​It's a bit hard to make out, but the progression is red, yellow, white, cyan, blue. 
 + 
 +[[http://​digistump.com/​wiki/​_media/​oak/​tutorials/​oak-rgb-led-rainbow.gif|{{http://​digistump.com/​wiki/​_media/​oak/​tutorials/​oak-rgb-led-rainbow.gif?​400}}]]
  
 ===== Conclusion ===== ===== Conclusion =====
oak/tutorials/rgb-led.1458794499.txt.gz · Last modified: 2016/03/23 21:41 by jwhendy