{"id":134,"date":"2015-05-04T19:24:12","date_gmt":"2015-05-04T19:24:12","guid":{"rendered":"https:\/\/drakesoe.wordpress.com\/?page_id=134"},"modified":"2015-05-04T19:24:12","modified_gmt":"2015-05-04T19:24:12","slug":"arduino-color-changing-leds","status":"publish","type":"page","link":"http:\/\/rodmilstead.com\/pt\/arduino-color-changing-leds\/","title":{"rendered":"Arduino: Color Changing LEDs"},"content":{"rendered":"<p>Sure you could multiple LEDs to get color combinations. \u00a0OR you could use just one LED that has color changing.<\/p>\n<p>You can control multiple colors and the delay between colors.<\/p>\n<p><a href=\"http:\/\/www.rapidtables.com\/web\/color\/RGB_Color.htm\" target=\"_blank\" rel=\"noopener noreferrer\">Want MORE colors? \u00a0Click here.\u00a0<\/a><\/p>\n<p>The circuit diagram is below.<\/p>\n<p>The sample code is below the circuit.\u00a0 Copy\/paste the ENTIRE PROGRAM into tinkercad.com.<\/p>\n<p>After you get your LED working then setup a new sequence with at least five NEW colors (see the chart linked above) and a different interval between each color. \u00a0Show me this for credit.<\/p>\n<p>Extension activity: add a button that will trigger the color changing sequence.<\/p>\n<p><strong>ingredients<\/strong><\/p>\n<p>1 RGB three color LED &#8211; this has FOUR legs. \u00a0The long leg is the ground.<\/p>\n<p>2 220 ohm resistors (red red brown)<\/p>\n<p>4 jumper wires<\/p>\n<p><strong>the recipe<\/strong><\/p>\n<p><a href=\"http:\/\/rodmilstead.com\/pt\/wp-content\/uploads\/2015\/05\/arduinorgb.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-135 alignnone\" src=\"http:\/\/rodmilstead.com\/pt\/wp-content\/uploads\/2015\/05\/arduinorgb.jpg?w=300\" alt=\"arduinoRGB\" width=\"300\" height=\"192\" srcset=\"http:\/\/rodmilstead.com\/pt\/wp-content\/uploads\/2015\/05\/arduinorgb.jpg 1974w, http:\/\/rodmilstead.com\/pt\/wp-content\/uploads\/2015\/05\/arduinorgb-300x192.jpg 300w, http:\/\/rodmilstead.com\/pt\/wp-content\/uploads\/2015\/05\/arduinorgb-768x493.jpg 768w, http:\/\/rodmilstead.com\/pt\/wp-content\/uploads\/2015\/05\/arduinorgb-1024x657.jpg 1024w, http:\/\/rodmilstead.com\/pt\/wp-content\/uploads\/2015\/05\/arduinorgb-1568x1006.jpg 1568w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\/*<br \/>\nAdafruit Arduino &#8211; Lesson 3. RGB LED<br \/>\n*\/<\/p>\n<p>int redPin = 11;<br \/>\nint greenPin = 10;<br \/>\nint bluePin = 9;<\/p>\n<p>\/\/uncomment this line if using a Common Anode LED<br \/>\n\/\/#define COMMON_ANODE<\/p>\n<p>void setup()<br \/>\n{<br \/>\npinMode(redPin, OUTPUT);<br \/>\npinMode(greenPin, OUTPUT);<br \/>\npinMode(bluePin, OUTPUT);<br \/>\n}<\/p>\n<p>void loop()<br \/>\n{<br \/>\nsetColor(255, 0, 0); \/\/ red<br \/>\ndelay(1000);<br \/>\nsetColor(0, 255, 0); \/\/ green<br \/>\ndelay(1000);<br \/>\nsetColor(0, 0, 255); \/\/ blue<br \/>\ndelay(1000);<br \/>\nsetColor(255, 255, 0); \/\/ yellow<br \/>\ndelay(1000);<br \/>\nsetColor(80, 0, 80); \/\/ purple<br \/>\ndelay(1000);<br \/>\nsetColor(0, 255, 255); \/\/ aqua<br \/>\ndelay(1000);<br \/>\n}<\/p>\n<p>void setColor(int red, int green, int blue)<br \/>\n{<br \/>\n#ifdef COMMON_ANODE<br \/>\nred = 255 &#8211; red;<br \/>\ngreen = 255 &#8211; green;<br \/>\nblue = 255 &#8211; blue;<br \/>\n#endif<br \/>\nanalogWrite(redPin, red);<br \/>\nanalogWrite(greenPin, green);<br \/>\nanalogWrite(bluePin, blue);<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sure you could multiple LEDs to get color combinations. \u00a0OR you could use just one LED that has color changing. You can control multiple colors and the delay between colors. Want MORE colors? \u00a0Click here.\u00a0 The circuit diagram is below. The sample code is below the circuit.\u00a0 Copy\/paste the ENTIRE PROGRAM into tinkercad.com. After you &hellip; <a href=\"http:\/\/rodmilstead.com\/pt\/arduino-color-changing-leds\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Arduino: Color Changing LEDs<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-134","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/rodmilstead.com\/pt\/wp-json\/wp\/v2\/pages\/134","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/rodmilstead.com\/pt\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/rodmilstead.com\/pt\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/rodmilstead.com\/pt\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/rodmilstead.com\/pt\/wp-json\/wp\/v2\/comments?post=134"}],"version-history":[{"count":0,"href":"http:\/\/rodmilstead.com\/pt\/wp-json\/wp\/v2\/pages\/134\/revisions"}],"wp:attachment":[{"href":"http:\/\/rodmilstead.com\/pt\/wp-json\/wp\/v2\/media?parent=134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}