Control leds with a potentiometer
In this instructable I will show you how to control 3 leds with a potentiometer and an arduino. I used 123d circuits but the procedure is the same if you use a breadboard or if you solder.
check out my new website : http://hacktronic.webs.com

Step 1: Parts and Tools

If you are not using 123d circuits these are the parts and tools needed to make this project:

Parts:
3 leds
wire
potentiometer( I used a 10 k ohm)
breadboard

Step 2: Place LEDs on the Board

Control leds with a potentiometer
Connect the leds to the breadboard all of the leds should all be in different rows on the breadboard.

Step 3: Connect negative rail on the breadboard

Control leds with a potentiometer
Wire all of the negative leads on the LEDs to the negative row on the breadboard and connect the negative row on the breadboard to the ground pin on the arduino.

Step 4: Place Potentiometer on Breadboard

Control leds with a potentiometer
Place potentiometer on the breadboard and connect the centre pin on the potentiometer to the arduino's analog pin 0 (A0) connect the potentiometer's left pin to the 5 volt pin on the arduino and connect the right hand side of the potentiometer to ground.

Step 5: Connect Led Pins

Control leds with a potentiometer
Connect led 1 to pin 13, led 2 to pin 12 and led 3 to pin 11 on the arduino.

Step 6: Upload Code to Arduino

Control leds with a potentiometer
Control leds with a potentiometer
Upload code to the arduino. If you are using the 123d circuits and you dont know how to upload code to the arduino you click on the arduino and select arduino code editor. Here is the code:



#define ledPin3 11
#define ledPin2 12
#define ledPin1 13
int potpin = 0;
int val;
void setup()
{
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
}

void loop()
{ Serial.print(val);
delay(500);
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 179);
if (val < 178){
digitalWrite(ledPin1, HIGH);
} else{
digitalWrite(ledPin1, LOW);
}

if (val < 90 ){
digitalWrite(ledPin2, HIGH);
}
else{
digitalWrite(ledPin2, LOW);
}

if (val < 36 ){
digitalWrite(ledPin3, HIGH);
}
else{
digitalWrite(ledPin3, LOW);
}
delay(15);
}

Step 7: Test

Control leds with a potentiometer
Test by uploading the code to the arduino and if you are on the 123d circuits click on the potentiometer with your mouse after you click the potentiometer a few times you should see the LEDs turn on slowly after you keep clicking on it.
 
 

Tag cloud

make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel