Introduction
The Internet of Things (IoT) is transforming the way we interact with everyday devices, making them smarter, interconnected, and more responsive. From smart homes to wearable devices, IoT is everywhere. One of the simplest yet most illustrative IoT projects is controlling LEDs using push buttons connected to an Arduino board.
In this project, we will build a system that allows three LEDs to be controlled independently using three push buttons. This project is perfect for beginners to learn about digital input and output, debouncing switches, and basic microcontroller programming.
Moreover, instead of immediately building the hardware, we can simulate the circuit using Tinkercad, a free online electronics simulator. This allows you to visualize the system in action and troubleshoot your design before working with physical components.
Project Objectives
By the end of this project, you will learn how to
Use push buttons to control LEDs.
Implement edge detection to toggle LEDs on and off.
Utilize Arduino's internal pull-up resistors for reliable button input.
Simulate circuits using Tinkercad Circuits before physically assembling them.
Build a foundation for more advanced IoT applications like smart lighting and home automation.
Required Components
To build this project, you will need the following components:
Arduino Uno (or any compatible Arduino board)
3 LEDs (preferably Red, Green, and Blue for easy identification)
3 push buttons
3 resistors (220–330 Ω) for current-limiting LEDs
Breadboard
Jumper wires
(Optional) 10 kΩ resistors if not using internal pull-up resistors
Circuit Diagram and Connections
The hardware setup is simple and ideal for breadboard prototyping:
Connect the anode (+) of each LED to a separate digital pin on the Arduino:
Red LED → Pin 10
Green LED → Pin 11
Blue LED → Pin 12
Connect the cathode (−) of each LED to GND through a 220 Ω resistor to prevent excessive current.
Connect each push button between a digital input pin and GND:
Button 1 → Pin 7
Button 2 → Pin 8
Button 3 → Pin 9
In the software, use the INPUT_PULLUP mode for the buttons. This enables the Arduino's internal pull-up resistors, eliminating the need for external pull-down resistors.
Simulating the Circuit in Tinkercad
Tinkercad is an excellent tool for simulating Arduino projects before building physical circuits. Here's how to simulate:
Go to Tinkercad Circuits and log in using your credentials.
Click Create New Circuit.
![1111]()
Drag an Arduino Uno and a breadboard onto the workspace.
![2025-09-21_09h36_48]()
Connect three LEDs and three push buttons according to the wiring described above.
Use 220 Ω resistors for LEDs.
Connect buttons to pins 7, 8, and 9, and use GND for the other side.
![2025-09-21_09h39_09]()
Click Code → Text and paste the Arduino code.
![2025-09-21_09h40_03]()
#define Pressed LOW
#define Released HIGH
#define LEDon HIGH
#define LEDoff LOW
// Define the pins for the buttons and LEDs
const byte switchPins[3] = {7, 8, 9};
const byte ledPins[3] = {10, 11, 12};
// Track the last button states
byte lastSwitchState[3] = {Released, Released, Released};
// Track the current LED states
bool ledState[3] = {false, false, false};
void setup() {
// Initialize button and LED pins
for (int i = 0; i < 3; i++) {
pinMode(switchPins[i], INPUT_PULLUP);
pinMode(ledPins[i], OUTPUT);
digitalWrite(ledPins[i], LEDoff);
}
}
void loop() {
// Loop through each button
for (int i = 0; i < 3; i++) {
byte currentState = digitalRead(switchPins[i]);
// Check for state change
if (currentState != lastSwitchState[i]) {
lastSwitchState[i] = currentState;
// If button is pressed, toggle the LED
if (currentState == Pressed) {
ledState[i] = !ledState[i];
digitalWrite(ledPins[i], ledState[i] ? LEDon : LEDoff);
}
}
}
}
Start the simulation and test by pressing the virtual buttons. Each LED should toggle independently.
![2025-09-21_09h42_32]()
Code Highlights
INPUT_PULLUP
Using INPUT_PULLUP ensures the button reads HIGH when unpressed and LOW when pressed. This prevents floating input problems.
Edge Detection
The code checks for a change in button state, ensuring that each press toggles the LED only once.
Scalability
Using arrays for pins and states makes the code clean and easy to extend to more buttons or LEDs.
Project Enhancements (IoT Ideas)
Once the basic project is working, you can make it IoT-ready:
Wi-Fi Integration: Connect the Arduino to Wi-Fi using an ESP8266 or ESP32 to control LEDs remotely.
Mobile App Control: Use Blynk, MIT App Inventor, or similar platforms to toggle LEDs from your smartphone.
Dashboard Monitoring: Visualize button presses and LED states on a cloud-based dashboard.
Automation: Combine sensors like temperature or motion sensors to automatically control LEDs.
Conclusion
This IoT LED project is an excellent starting point for anyone learning Arduino and basic IoT concepts. It demonstrates how digital input and output work, how to toggle devices using push buttons, and how to simulate circuits in Tinkercad.
By extending this project, you can create smart home lighting, IoT dashboards, or other interactive devices. Simulations in Tinkercad make experimentation safe, fast, and error-free before moving to physical hardware.