Let there be light!

Description

I used 3 potentiometers to vary the brightness of 3 LEDs individually, wherein each LED can be controlled independently of the others. This setup enabled me to carry out some interesting effects with dimming and rising of the LEDs. The video can be seen here – https://goo.gl/photos/y1YiUhkJ8XSZjCb58

Components

1 Arduino Uno
3 LEDs
3 220Ω Resistors
3 potentiometers
1 Breadboard
Jumper wires
USB cable

int potPin = 0;
int potPin1 = 1;
int potPin2 = 2; // Analog input pin that the potentiometer is attached to
int potValue = 0;
int potValue1 = 0;
int potValue2 = 0; // value read from the pot
int led = 9;
int led1 = 10; // PWM pin that the LED is on. n.b. PWM 0 is on digital pin 9
int led2 = 11;

void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
// declare the led pin as an output:
pinMode(led, OUTPUT);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
}

void loop() {
potValue = analogRead(potPin);
potValue1 = analogRead(potPin1);
potValue2 = analogRead(potPin2); // read the pot value
analogWrite(led, potValue/4);
analogWrite(led1, potValue1/4);
analogWrite(led2, potValue2/4); // PWM the LED with the pot value (divided by 4 to fit in a byte)
Serial.println("hello"); // print the pot value back to the debugger pane
delay(10); // wait 10 milliseconds before the next loop
}

IMG_20160920_230003      IMG_20160920_230144      IMG_20160920_231022

Leave a Reply