Assignment
Bland, boring, basic potentiometer setup. No time to turn it into anything cool. I set up two potentiometers and used one to control the brightness of the three LEDs and the other to control their on/off frequency.
Components Used
Arduino Board
Breadboard
Potentiometers (2)
LEDs (Green, Blue, Yellow)
Jumpers (3)
220 Ohm Resistors (3)
Lengths of wire (13)
Arduino Code
/*
* One potentiometer controls the brightness of the LEDs and one controls their frequency
*/
int potPin1 = 1;
int potPin2 = 2;
int pCellPin1 = 0;
int ledPin = 9; // select the pin for the LED
int input0val = 0;
int input1val = 0; // variable to store the value coming from pot 1
int input2val = 0; //variable to store the value coming from pot 2
int brightval = 0;
int delayval = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
input0val = analogRead(pCellPin1);
input1val = analogRead(potPin1); // read the value from the sensor, between 0 - 1024
input2val = analogRead(potPin2); // read the value from the sensor, between 0 - 1024
brightval = input1val;
delayval = input2val;
Serial.print("photocell: ");
Serial.print(input0val);
Serial.print(" brightness: ");
Serial.println(brightval);
Serial.print(" delay: ");
Serial.println(delayval);
analogWrite(9, brightval/4); // analogWrite can be between 0-255
analogWrite(10, brightval/4);
analogWrite(11, brightval/4);
delay(delayval);
analogWrite(9, 0); // analogWrite can be between 0-255
analogWrite(10, 0);
analogWrite(11, 0);
delay(delayval);
}
Item
Potentiometers controlling LED Brightness & Blink
Comments
hahaha, oh wes :) at least
hahaha, oh wes :) at least you're upfront about it! =P