Education Technology

Fantastic LMS and instructors, well laid out, good speed, and explains.
  • Home
  • Blog
  • Education Technology
  • Push Button Control System For Light ON/OFF Using Aurdino Uno

Push Button Control System For Light ON/OFF Using Aurdino Uno

  • Posted by inkinccorporation
  • Categories Education Technology
  • Date April 4, 2025
  • Comments 0 comment

3.3K

In this article, you’ll learn how make a Push Button Control System for Light ON/OFF Push Button Control System for Light ON/OFF using Aurdino Uno.

Want to be able to just click a button and the light goes on? This project will take you through a step-by-step process in the development of a simple push-button control system where an LED will be operated with an Arduino Uno. It is a wonderful introduction to the great world of Arduino and electronics!

Hardware Needed:

  • Arduino Uno
  • Push Button
  • LED

Schematics and hardware connections

Push Button Control System for Light ON/OFF using Aurdino Uno

Connect one terminal of push button to pin 4 and other to GND.
We are using Led as output when button is pressed, you can replace it with any required action you want.

Code

The Arduino code defines the functionality of the push button control system.

You Might Be Interested In

//Assigning the pins to variables
int led = 13;
int button_pin = 4;

// In setup() we set the button pin as a digital input and we activate the internal pull-up resistor using the INPUT_PULLUP macro, led pin as output and begin a serial communication between host and arduino to see the status.
void setup() {
pinMode(button_pin, INPUT_PULLUP);
pinMode(led, OUTPUT);
Serial.begin(9600);
}

void loop(){
// Read the value of the input. It can either be 1 or 0
int buttonValue = digitalRead(button_pin);
Serial.println(buttonValue);
if (buttonValue == LOW){
Serial.println(“button pressed”);
digitalWrite(led,HIGH);
}

else {
Serial.println(“button released”);
digitalWrite(led, LOW);
}
}

Code Explanation

The provided code controls an LED with a push button using an Arduino Uno and includes serial communication for monitoring the button state. Let’s understand each statement.

Variable Initialization:

  • int led = 13;: This line assigns the number 13 to the variable led. This represents the digital pin on the Arduino Uno connected to the LED.
  • int button_pin = 4;: This line assigns the number 4 to the variable button_pin. This represents the digital pin connected to the push button.

Setup Function:

  • pinMode(button_pin, INPUT_PULLUP);: This line sets the button_pin as a digital input. The INPUT_PULLUP macro activates an internal pull-up resistor on the Arduino. This resistor ensures a constant HIGH signal when the button is not pressed, simplifying the code.
  • pinMode(led, OUTPUT);: This line sets the led pin as a digital output, allowing the Arduino to control the LED’s state (on/off).
  • Serial.begin(9600);: This line initiates serial communication between the Arduino and a computer (host) at a baud rate of 9600 bits per second. This allows you to see the button’s state on the computer software connected to the Arduino.

Loop Function:

  • int buttonValue = digitalRead(button_pin);: This line reads the current state of the button connected to button_pin and stores it in the variable buttonValue. Due to the pull-up resistor, buttonValue will be HIGH when the button is not pressed and LOW when pressed.
  • Serial.println(buttonValue);: This line prints the value of buttonValue (either 1 or 0) to the serial monitor, allowing you to see the button’s state on the computer software.
  • if (buttonValue == LOW) { ... } else { ... }: This is an if-else statement that checks the value of buttonValue.
    • If buttonValue is LOW (meaning the button is pressed):
      • Serial.println(“button pressed”);: This line prints “button pressed” to the serial monitor.
      • digitalWrite(led, HIGH);: This line turns the LED on by setting the led pin to HIGH.
    • Else (meaning the button is not pressed):
      • Serial.println(“button released”);: This line prints “button released” to the serial monitor.
      • digitalWrite(led, LOW);: This line turns the LED off by setting the led pin to LOW.

Source link

  • Share:
inkinccorporation

Previous post

GGSIPU Launches Dual MSc Degree Program in Collaboration with AGH University, Poland 2025
April 4, 2025

Next post

Backlinks vs Referring domain: Know the difference
April 4, 2025

You may also like

20260402security.jpg
Addressing Outdated Technology and Unprepared Staff in Education — Campus Technology
April 15, 2026
odishas-berhampur-university-inks-pact-with-kolkatas-national-library.jpg
Odisha’s Berhampur University inks pact with Kolkata’s National Library, ETEducation
April 14, 2026
proof-ai-tutor-feat-scaled-1-2000×1334.jpg
The Quest to Build a Better AI Tutor
April 14, 2026

Leave A Reply

Your email address will not be published. Required fields are marked *

Product categories

  • Accessories (7)
  • Cookware (3)
  • Culinary (5)
  • Postcard (3)
  • Uncategorized (0)

Products

  • A Beginner Crash Course Guide
    A Beginner Crash Course Guide $9.00 Add to cart
  • A Magic School for Girls Chapter
    A Magic School for Girls Chapter $9.50 Add to cart
  • A Memoir of a Life Interrupted
    A Memoir of a Life Interrupted $9.60 Add to cart