Remove these ads by
Signing UpStep 1: Gather your materials.
-An Arduino
-Some LEDs (I suggest starting with 7, but you can use 14 if you want to!)
-An insulated wire about as long as the Arduino.
At minimum, the wire can be 1 1/2in (or 4cm, for those readers that like the metric system. Go metric!). As proof that it will work, you can insert the wire into the GND pin next to the AREF pin. If the wire can reach Digital I/O pin 0 without much trouble, you're good to go.
Don't worry about the LED's forward voltage, because you'll only be using them in short bursts that won't be enough to fry them. My LEDs were each at around 3FV, or 3 forward volts. This is the common amount for most LEDs. If you do decide to use LEDs with a smaller forward voltage, beware. Also, if you adapt the program sampled here and change the delay speed, you might fry your pretty lights! Be careful! If you DO plan to leave an LED on for a prolonged period of time, a 100ohm resistor connected to it should do the trick.









































Visit Our Store »
Go Pro Today »




20ma is higher than many LEDs can handle. Ones that need 330 Ohm resistors typically use around 10ma.
What resistor you need is determined by an individual LEDs current rating. That value does vary depending on the particular LED you are using. So unless you specify what current LEDs to use you cannot really specify what current limiting resistor is needed either.
Must be why there is that online LED calculator you used don't you think?
I would also appreciate if anybody didn't take sides in this argument, because it isn't one.
Voltage drop when talking about LED's (and other passive components) is the voltage at which internal resistance begins to rise. As more voltage is applied the resistance will increase and the internal circuits will begin to heat up. If the voltage goes too high for too long, the internal components will get hot enough to melt, and that's when the LED burns out. An LED with a 3v drop can usually handle up to 3.5v or so for extended periods of time. Above that they will eventually burn out, with higher voltages causing it to burn out faster.
Ohm's law is I=V/R, or Amps = Volts/Ohms.
First of all, source amps don't matter except as far as resistor maximum capacity. For example, you don't want to use a 2 amp resistor with a 20 amp source - it will fry the resistor and then your whole project and possibly kill you, because 20 amps is way more than necessary to the job.
So, if we have a 5v source and we want to get that down to 3v @ 20ma, then we need to add enough resistance to drop 2 volts at 20ma. Thus:
Ohms = 2V/0.02a
Which is 100.
To run a 3v LED at 10ma, you need a 200 ohm resistor (2v/0.01a=200).
To run a 3v LED at 20ma from a 9v source you need a 300 ohm resistor (6v/0.02=300).
All of this is in the linked instructable you wouldn't read because it was referred to you by a 13 year old. Who's grown up here?
i have changed the code so you can use the pot for 14 led`s
here`s the code, have fun!!
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
pinMode(1, OUTPUT);
pinMode(0, OUTPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
digitalWrite(13, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(12, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(13, LOW);
digitalWrite(11, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(12, LOW);
digitalWrite(10, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(11, LOW);
digitalWrite(9, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(10, LOW);
digitalWrite(8, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(9, LOW);
digitalWrite(7, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(8, LOW);
digitalWrite(6, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(4, LOW);
digitalWrite(3, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(3, LOW);
digitalWrite(2, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(2, LOW);
digitalWrite(1, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(1, LOW);
digitalWrite(0, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(1, LOW);
digitalWrite(0, LOW);
}
only a quick thought if it helps or gives you any ideas.
is not work,
Put a LED on pin 13 and connect the other pin to ground
" " " " " 12 " " " " " " "
" " " " " 11 " " " " " " "
" " " " " 10 " " " " " " "
" " " " " 9 " " " " " " "
" " " " " 8 " " " " " " "
" " " " " 7 " " " " " " "
Put the center pin of the potentiometer to analog pin 0
Put a side pin of the potentiometer (either one) to ground
The other side pin to +5V
*/
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
digitalWrite(13, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(12, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(13, LOW);
digitalWrite(11, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(12, LOW);
digitalWrite(10, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(11, LOW);
digitalWrite(9, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(10, LOW);
digitalWrite(8, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(9, LOW);
digitalWrite(7, HIGH);
delay(sensorValue);
sensorValue = analogRead(sensorPin);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
}
We all start somewhere and like myself, we learn from each other.
I have just started on the journey so lets see where it takes us :-)
Other than that, great instructable! (5*)
Like you I say, other than that, great instructable!
(By the way, if you want to know the exact cost of the LEDs, it was $1.05. I got each one for 15 cents.)
And if you're trying to be a smart-mouth (or smart-text, whichever you prefer,) please stop. I mean that in the nicest possible way.