Arduino Uno With Blinking LED and Potentiometer
by Conner Provins in Circuits > Arduino
31 Views, 0 Favorites, 0 Comments
Arduino Uno With Blinking LED and Potentiometer
I made and Arduino Uno with a blinking LED, the frequency of which you can adjust using a potentiometer.
Instructor: Mr. Sweet
Source: Mechatronics 1 class, SparkFun kit
Supplies
You will need:
- 1 Arduino Uno
- 1 small breadboard
- 1 LED (I used a yellow one)
- 1 potentiometer
- 1 100 Ohm resistor
- 8 jumper wires (I recommend using black for negative and red for positive)
- 1 power source (I used my Chromebook)
- 1 cord to connect the Arduino to the power source
Placing Your Components
Place your LED, potentiometer, and resistor as shown in the image. (The short leg (anode) of the LED should connect to one end of the resistor)
Wiring Your Circuit
Place your wires as shown in the image. There should be a wire from the long leg (cathode) of the LED to pin 12 (red) (the image shows it connecting to pin 13, just ignore that and connect it to pin 12), a wire from negative to pin GND (ground) (black), a wire from positive to pin 5V (red), a wire from the potentiometer cathode to positive (blue), a wire from the potentiometer middle pin to A1 (green), and a wire from the potentiometer anode to negative (brown).
Coding Your Circuit
Open the Arduino Cloud Editor on your power source, create a new sketch, and paste this exact code:
int sensorPin = A1;
int ledPin = 12;
int sensorValue = 0;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
digitalWrite(ledPin, HIGH);
delay(sensorValue);
digitalWrite(ledPin, LOW);
delay(sensorValue);
}
Running Your Circuit
Connect your Arduino Uno to your power source with the cord then press "select device" in the Arduino Cloud Editor and select the port your Arduino is connected to. Click the check mark to compile the code then the arrow to send it to the Arduino. After this, your circuit should run as intended. Congratulations!