This lab creates a circuit with two LEDs, two buttons, and a potentiometer. The two buttons control which LED is turned on, and the potentiometer controls the brightness of the LEDs when they are on.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Connect the First LED to the Arduino
The first step is to connect the first LED to the circuit and Arduino.
- Place one LED on the breadboard and connect the cathode to the negative rail of the breadboard.
- Place a 220Ω resister on the anode leg of the LED and connect the other end to pin 10 on the Arduino.
- Connect the negative rail on the breadboard to the grounding pin on the Arduino.
Step 2: Add the Second LED
Add another LED to the circuit the same way as the other LED but connect this one to pin 11 on the Arduino.
Step 3: Add the Potentiometer
This step adds in the potentiometer that we will use to control the LED brightness when the LEDs are turned on.
- Add the potentiometer to the breadboard in the middle.
- Connect the first pin on the pot to the positive rail on the breadboard.
- Connect the last pin to the negative rail on the breadboard.
- Connect the middle pin on the potentiometer to the analog input pin labeled A2.
Step 4: Add the First Button
This step will add in the button that will control the first LED.
- Connect a momentary push button to the middle of the breadboard.
- Connect the bottom-left pin to the positive rail of the breadboard.
- Connect the bottom-right pin to pin 3 on the Arduino board.
- Connect the top-right pin of the button to a 10KΩ resistor and connect that to the negative rail on the breadboard.
Step 5: Add in the Second Button
Add in another button the same as the last one but connect the bottom-right pin to pin 4 on the Arduino board. Connect the top negative rail to the bottom rail to ground the buttons.
Step 6: Code
Download this code and compile and upload it to your Arduino Uno.