A beginner-friendly Arduino project for controlling the brightness of two LEDs using two buttons.
This project is designed for learning Arduino basics, digital input, PWM, and button control.
Two buttons control the brightness of two LEDs:
- UP button → increases brightness
- DOWN button → decreases brightness
- Brightness range → 0–255 (PWM)
- LEDs → controlled with PWM on pins 9 and 10
This is one of my first Arduino projects.
These projects document my learning journey with Arduino and Embedded Systems.
Feel free to use, modify, and learn from the code.
If this project helps you, a ⭐ on the repository is appreciated.
- Arduino Mega 2560
- 2x LEDs
- 2x 220Ω resistors
- 2x push buttons
- Breadboard
- Jumper wires
- USB cable
LEDs:
- LED 1 → 220Ω resistor → Pin 9 (PWM) → Cathode to GND
- LED 2 → 220Ω resistor → Pin 10 (PWM) → Cathode to GND
Buttons:
- UP button → Pin 2 → other side to GND
- DOWN button → Pin 3 → other side to GND
- Buttons use
INPUT_PULLUP
See the Photos folder for wiring diagrams and project photos.
- Open Arduino IDE.
- Open
ArduinoIDE/BrightnessDownUpButtons.ino. - Select Tools → Board → Arduino Mega 2560.
- Select Tools → Port → Your COM port.
- Click Upload.
A Visual Studio Code version of the project is also included.
Open the VisualStudioCode/ folder and use the Arduino extension to upload the project.
The brightness of the LEDs is controlled using PWM (Pulse Width Modulation).
analogWrite(pin, 0)→ LED offanalogWrite(pin, 255)→ maximum brightness- Values between
0and255→ different brightness levels
The buttons use INPUT_PULLUP, which means the Arduino's internal pull-up resistors are used instead of external resistors.
A short delay is also used for simple button debouncing.
analogWrite(LED_PIN, brightness);LEDsBrightness2Buttons/
│
├── ArduinoIDE/
│ └── BrightnessDownUpButtons.ino
│
├── VisualStudioCode/
│ └── BrightnessDownUpButtonsVSC/
│
├── Photos/
│ └── ...
│
├── .gitignore
├── LICENSE
└── README.md
- Digital input and output (
INPUT,OUTPUT,INPUT_PULLUP) - PWM and
analogWrite() - Reading buttons with
digitalRead() - Simple button debouncing
- Basic program flow (
setup(),loop()) - Working with Arduino pins and a breadboard
- Check LED polarity.
- Check that the resistor is 220Ω.
- Verify the pin numbers in the code.
- Check the GND connection.
- Check the connections to pins 2 and 3.
- Make sure the other side of each button is connected to GND.
- Check the button orientation on the breadboard.
- Make sure Arduino Mega 2560 is selected.
- Check the USB cable.
- Check the selected COM port.
- Try another USB port.
This project is licensed under the MIT License.
See LICENSE for details.
Made while learning Arduino and Embedded Systems.