Adjustable Flashing LED Using a POT and an Arduino
by Evanlgks in Circuits > Arduino
35 Views, 0 Favorites, 0 Comments
Adjustable Flashing LED Using a POT and an Arduino
In my Mech 1 class, ran by Mr. Sweet, we used the Sparkfun SIK and used the diagram to build the structure, then used the built in code to test it out. Finally I remastered the code to fit my diameters, and got it to work.
Supplies
1 LED
1POT
1 Resistor
1 Arduino
6 Wires
Code I used
int sensorPin = A0;
int ledPin = 12;
int sensorValue = 0;
void setup() {
pinMode(12, OUTPUT) ;
}
void loop() {
sensorValue = analogRead(sensorPin) ;
digitalWrite(12, HIGH) ;
delay(sensorValue);
digitalWrite(12, LOW);
delay(sensorValue);
}
The Steps
- put your led down, and attach a resistor to the positive end
- Set your POT away from the led, and attach a wire to the left side of the POT to your positive side on the breadboard and the right wire to the negative side.
- The middle wire that goes into the POT should go in A0 slot
- Connect a wire from the negative side of the breadboard to the ground on the Arduino, and connect a wire from the positive side of the breadboard to A5
- Connect the positive side of the led to pin 13