Course Content
📘 MODULE 11 – Edge Avoiding Robot
📦 MODULE 12 – Smart Multi-Function Robot (Mega Project)
Arduino Hands-On Programming and Robotics Course

📖 Lesson 4.4 – Buzzer/LED Alert Logic

🎯 Learning Objectives

After completing this lesson, students will be able to:

✅ Understand Alert Systems

✅ Use an IR Sensor to trigger alerts

✅ Control an LED and Buzzer simultaneously

✅ Create obstacle warning systems

✅ Understand sensor-based automation

✅ Build a simple security and detection system


1. Introduction

In the previous lesson, we used an LED to indicate obstacle detection.

Now we will improve the system.

Instead of only turning ON an LED, Arduino will activate:

  • LED Alert
  • Buzzer Alert

This creates a warning system that can both be seen and heard.

Such systems are commonly used in:

  • Security Systems
  • Parking Sensors
  • Robots
  • Industrial Machines
  • Obstacle Detection Systems

2. Project Overview

The system works as:

 
Obstacle

IR Sensor

Arduino UNO

LED + Buzzer Alert
 

When an obstacle is detected:

✅ LED Turns ON

✅ Buzzer Sounds


3. Components Required

Component Quantity
Arduino UNO 1
IR Obstacle Sensor Module 1
LED 1
220Ω Resistor 1
Active Buzzer 1
Breadboard 1
Jumper Wires As Required
USB Cable 1

4. Circuit Connections

IR Sensor Module

IR Sensor Arduino UNO
VCC 5V
GND GND
OUT D2

LED

LED Arduino UNO
Anode (+) D13 through 220Ω resistor
Cathode (-) GND

Active Buzzer

Buzzer Arduino UNO
Positive (+) D8
Negative (-) GND

Circuit Diagram

 
IR Sensor

VCC -----> 5V
GND -----> GND
OUT -----> D2

LED

D13 -----> Resistor -----> LED -----> GND

Buzzer

D8 ------> Buzzer (+)
GND -----> Buzzer (-)
 

5. Alert Logic

No Obstacle

 
LED OFF
Buzzer OFF
 

Obstacle Detected

 
LED ON
Buzzer ON
 

6. Algorithm

Step 1

Read IR Sensor

Step 2

Obstacle Detected?

YES

LED ON

Buzzer ON

NO

LED OFF

Buzzer OFF

Repeat Forever


7. Arduino Program

 
int sensorPin = 2;
int ledPin = 13;
int buzzerPin = 8;

void setup()
{
pinMode(sensorPin, INPUT);

pinMode(ledPin, OUTPUT);

pinMode(buzzerPin, OUTPUT);
}

void loop()
{
if(digitalRead(sensorPin) == LOW)
{
digitalWrite(ledPin, HIGH);

digitalWrite(buzzerPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);

digitalWrite(buzzerPin, LOW);
}
}
 

8. Program Explanation

Read Sensor

 
digitalRead(sensorPin)
 

Checks whether an obstacle exists.


LED Alert

 
digitalWrite(ledPin, HIGH);
 

Turns ON warning LED.


Buzzer Alert

 
digitalWrite(buzzerPin, HIGH);
 

Activates buzzer.


Alert OFF

 
digitalWrite(ledPin, LOW);

digitalWrite(buzzerPin, LOW);
 

Turns OFF both devices.


9. Testing the System

Test 1 – No Obstacle

Expected:

 
LED OFF
Buzzer OFF
 

Test 2 – Hand Detection

Place your hand in front of sensor.

Expected:

 
LED ON
Buzzer ON
 

Test 3 – Remove Hand

Expected:

 
LED OFF
Buzzer OFF
 

10. Enhanced Program with Serial Monitor

 
 
int sensorPin = 2;
int ledPin = 13;
int buzzerPin = 8;

void setup()
{
  pinMode(sensorPin, INPUT);

  pinMode(ledPin, OUTPUT);

  pinMode(buzzerPin, OUTPUT);

  Serial.begin(9600);
}

void loop()
{
  if(digitalRead(sensorPin) == LOW)
  {
    digitalWrite(ledPin, HIGH);

    digitalWrite(buzzerPin, HIGH);

    Serial.println("Obstacle Detected");
  }
  else
  {
    digitalWrite(ledPin, LOW);

    digitalWrite(buzzerPin, LOW);

    Serial.println("Area Clear");
  }

  delay(200);
}

11. Practical Applications

Parking Assistance System

Vehicle approaches obstacle.

Warning buzzer activates.


Security Alarm

Person detected.

Alarm sounds.


Robot Safety System

Obstacle detected.

Warning generated.


Industrial Safety

Machine detects nearby object.

Alert activated.


Smart Gate System

Vehicle detected.

Notification generated.


12. Improving the Alert System

Instead of a continuous buzzer:

Use a beeping pattern.

Example:

 
digitalWrite(buzzerPin, HIGH);
delay(200);

digitalWrite(buzzerPin, LOW);
delay(200);
 

Result:

 
Beep... Beep... Beep...
 

13. Variable Alert Speed

Close obstacle:

Fast beeping.


Far obstacle:

Slow beeping.

This concept is used in vehicle reverse parking sensors.


14. Common Beginner Mistakes

Mistake 1

Connecting buzzer polarity incorrectly.


Mistake 2

Using a passive buzzer without tone generation.


Mistake 3

Wrong sensor output logic.

Some modules may use opposite logic.


Mistake 4

Loose wiring connections.


15. Troubleshooting

LED Works But Buzzer Doesn’t

Check:

  • Buzzer polarity
  • Buzzer pin connection
  • Buzzer type

Buzzer Always ON

Check:

  • Sensor calibration
  • Output logic

No Detection

Check:

  • IR sensor wiring
  • Detection range

Unstable Alerts

Check:

  • Potentiometer adjustment
  • Sunlight interference

16. Mini Challenge

Modify the system so:

Obstacle Detected

LED Blinks

AND

Buzzer Beeps

instead of remaining continuously ON.


📊 Summary

In this lesson, we learned:

✅ LED Alert Logic

✅ Buzzer Alert Logic

✅ Obstacle Warning Systems

✅ Sensor-Based Automation

✅ Security and Safety Applications

This project demonstrates how sensors can automatically trigger warning devices when an object is detected.


📖 Key Terms

Alert System

A system that provides warnings.

Active Buzzer

A buzzer that produces sound when power is applied.

Detection Zone

The area monitored by the sensor.

Automation

Automatic operation without human intervention.

Warning Signal

Visual or audible indication of an event.


🎯 Quiz

1. Which component provides an audible alert?

A. LED

B. Buzzer ✅

C. Resistor

D. Sensor


2. Which pin is connected to the buzzer in this lesson?

A. D2

B. D13

C. D8 ✅

D. A0


3. What happens when an obstacle is detected?

A. LED ON and Buzzer ON ✅

B. LED OFF and Buzzer OFF

C. Arduino OFF

D. Sensor OFF


4. Which sensor triggers the alert?

A. LDR

B. DHT11

C. IR Sensor ✅

D. Ultrasonic Sensor


5. One application of this project is:

A. Parking Sensor System ✅

B. Weather Station

C. Calculator

D. Printer


🏠 Assignment

Task 1

Build the LED and buzzer alert system.

Task 2

Modify the buzzer to beep instead of staying continuously ON.

Task 3

Test obstacle detection at different distances.

Task 4

Create a table showing detection distance and alert response.

Task 5

Explain how this system can be used in a vehicle parking sensor.

Scroll to Top