Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Obstacle Detection System with Buzzer Alert

View and Edit Project In Cirkit DesignerImage of Arduino UNO Obstacle Detection System with Buzzer Alert

Circuit Documentation

Summary

This circuit is designed to detect obstacles using an FC-51 IR Obstacle Sensor and trigger a buzzer when an obstacle is detected. The circuit is controlled by an Arduino UNO microcontroller.

Component List

Buzzer

Arduino UNO

FC-51 IR Obstacle Sensor

Wiring Details

Buzzer

Arduino UNO

FC-51 IR Obstacle Sensor

Code Documentation

// Pin definitions
const int sensorPin = 2;  // Obstacle avoidance module
const int buzzerPin = 3;  // Buzzer

void setup() {
  pinMode(sensorPin, INPUT);   // Set the sensor pin as input
  pinMode(buzzerPin, OUTPUT);  // Set the buzzer pin as output
  
  // Initialize serial communication for debugging (optional)
  Serial.begin(9600);
}

void loop() {
  // Read the sensor state
  int sensorState = digitalRead(sensorPin);

  if (sensorState == LOW) {  // LOW means obstacle detected for most modules
    digitalWrite(buzzerPin, HIGH); // Turn the buzzer on
    Serial.println("Obstacle detected!"); // Debug message (optional)
  } else {
    digitalWrite(buzzerPin, LOW);  // Turn the buzzer off
    Serial.println("No obstacle."); // Debug message (optional)
  }

  delay(100); // Small delay to avoid rapid switching
}

This code initializes the sensor and buzzer pins, reads the sensor state in the loop, and turns the buzzer on or off based on the sensor state. Debug messages are printed to the serial monitor for optional debugging.