Difference between revisions of "Cylon LEDs"
Jump to navigation
Jump to search
(Created page with "__NOTOC__ ==Introduction== '''Cylon LEDs''' In this experiment, we will create a Cylon (Battlestar Galactica) effect with LEDs. I get this request quite a lot when people are f...") |
Notyou007a (talk | contribs) |
||
(7 intermediate revisions by one other user not shown) | |||
Line 18: | Line 18: | ||
==Schematic== | ==Schematic== | ||
− | + | [[File:Cylon_schem.jpg]] | |
==Fritzing== | ==Fritzing== | ||
− | + | [[File:Cylon_bb.jpg]] | |
==Code== | ==Code== | ||
<pre> | <pre> | ||
+ | //code for Cylon - I am sure this could be more elegant! | ||
+ | //bpw 2/11/22 | ||
+ | |||
+ | int pinled1 = 6; | ||
+ | int pinled2 = 7; | ||
+ | int pinled3 = 8; | ||
+ | int pinled4 = 9; | ||
+ | int pinled5 = 10; | ||
+ | int pinled6 = 11; | ||
+ | int pinled7 = 12; | ||
+ | int pinled8 = 13; | ||
+ | int t = 50; | ||
+ | void setup() | ||
+ | { | ||
+ | pinMode(pinled1, OUTPUT); | ||
+ | pinMode(pinled2, OUTPUT); | ||
+ | pinMode(pinled3, OUTPUT); | ||
+ | pinMode(pinled4, OUTPUT); | ||
+ | pinMode(pinled5, OUTPUT); | ||
+ | pinMode(pinled6, OUTPUT); | ||
+ | pinMode(pinled7, OUTPUT); | ||
+ | pinMode(pinled8, OUTPUT); | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | digitalWrite(pinled1, HIGH); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled2, HIGH); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled1, LOW); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled3, HIGH); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled2, LOW); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled4, HIGH); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled3, LOW); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled5, HIGH); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled4, LOW); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled6, HIGH); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled5, LOW); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled7, HIGH); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled6, LOW); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled8, HIGH); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled7, LOW); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled7, HIGH); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled8, LOW); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled6, HIGH); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled7, LOW); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled5, HIGH); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled6, LOW); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled4, HIGH); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled5, LOW); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled3, HIGH); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled4, LOW); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled2, HIGH); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled3, LOW); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled1, HIGH); | ||
+ | delay(t); | ||
+ | digitalWrite(pinled2, LOW); | ||
+ | delay(t); | ||
+ | |||
+ | } | ||
</pre> | </pre> | ||
==Troubleshooting== | ==Troubleshooting== | ||
+ | Probably the easiest way to troubleshoot LEDs is to power them. Take the wire that goes to the arduino output pin and touch it to 5V to see that the LED lights up. If it does not, turn the LED around and try again. LEDs are pretty hearty as long as you have a 1K resistor in series with them. | ||
+ | |||
+ | [[Category:HOWTO]] |
Latest revision as of 23:52, 25 June 2015
Introduction
Cylon LEDs In this experiment, we will create a Cylon (Battlestar Galactica) effect with LEDs. I get this request quite a lot when people are first starting to program arduinos.
Components Needed
- Freeduino or Arduino or clone
- USB cable for Freeduino
- Freeduino development software - download here!
- Solderless Breadboard
- Hookup wire 22gauge solid
- 8 LEDs -same color is preferable
- 8 1K resistors
How to
- See the fritzing diagram
Schematic
Fritzing
Code
//code for Cylon - I am sure this could be more elegant! //bpw 2/11/22 int pinled1 = 6; int pinled2 = 7; int pinled3 = 8; int pinled4 = 9; int pinled5 = 10; int pinled6 = 11; int pinled7 = 12; int pinled8 = 13; int t = 50; void setup() { pinMode(pinled1, OUTPUT); pinMode(pinled2, OUTPUT); pinMode(pinled3, OUTPUT); pinMode(pinled4, OUTPUT); pinMode(pinled5, OUTPUT); pinMode(pinled6, OUTPUT); pinMode(pinled7, OUTPUT); pinMode(pinled8, OUTPUT); } void loop() { digitalWrite(pinled1, HIGH); delay(t); digitalWrite(pinled2, HIGH); delay(t); digitalWrite(pinled1, LOW); delay(t); digitalWrite(pinled3, HIGH); delay(t); digitalWrite(pinled2, LOW); delay(t); digitalWrite(pinled4, HIGH); delay(t); digitalWrite(pinled3, LOW); delay(t); digitalWrite(pinled5, HIGH); delay(t); digitalWrite(pinled4, LOW); delay(t); digitalWrite(pinled6, HIGH); delay(t); digitalWrite(pinled5, LOW); delay(t); digitalWrite(pinled7, HIGH); delay(t); digitalWrite(pinled6, LOW); delay(t); digitalWrite(pinled8, HIGH); delay(t); digitalWrite(pinled7, LOW); delay(t); digitalWrite(pinled7, HIGH); delay(t); digitalWrite(pinled8, LOW); delay(t); digitalWrite(pinled6, HIGH); delay(t); digitalWrite(pinled7, LOW); delay(t); digitalWrite(pinled5, HIGH); delay(t); digitalWrite(pinled6, LOW); delay(t); digitalWrite(pinled4, HIGH); delay(t); digitalWrite(pinled5, LOW); delay(t); digitalWrite(pinled3, HIGH); delay(t); digitalWrite(pinled4, LOW); delay(t); digitalWrite(pinled2, HIGH); delay(t); digitalWrite(pinled3, LOW); delay(t); digitalWrite(pinled1, HIGH); delay(t); digitalWrite(pinled2, LOW); delay(t); }
Troubleshooting
Probably the easiest way to troubleshoot LEDs is to power them. Take the wire that goes to the arduino output pin and touch it to 5V to see that the LED lights up. If it does not, turn the LED around and try again. LEDs are pretty hearty as long as you have a 1K resistor in series with them.