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

Arduino UNO-Based Smart Light with PIR Sensor and Bluetooth Control

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Smart Light with PIR Sensor and Bluetooth Control

Circuit Documentation

Summary

This circuit is designed to control an LED and a buzzer using a PIR sensor, a pushbutton, and a Bluetooth module. The Arduino UNO microcontroller is the central unit that processes inputs from the PIR sensor and the pushbutton, and controls the LED and buzzer accordingly. The Bluetooth module allows for remote control of the LED.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. LED: Two Pin (red)

    • Description: A red LED with two pins.
    • Pins: cathode, anode
  3. Buzzer

    • Description: A simple buzzer with two pins.
    • Pins: PIN, GND
  4. Pushbutton

    • Description: A pushbutton with four pins.
    • Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)
  5. Bluetooth HC-06

    • Description: A Bluetooth module for wireless communication.
    • Pins: VCC, GND, TXD, RXD
  6. Resistor

    • Description: A resistor with a resistance of 220 Ohms.
    • Pins: pin1, pin2
  7. PIR Sensor

    • Description: A Passive Infrared (PIR) sensor for motion detection.
    • Pins: GND, VCC, Data

Wiring Details

Arduino UNO

LED: Two Pin (red)

Buzzer

Pushbutton

Bluetooth HC-06

Resistor

PIR Sensor

Code Documentation

Arduino UNO Code

int pirPin = 2;          
int ledPin = 9;          
int buzzerPin = 10;      
int buttonPin = 3;       
int bluetoothPin = 4;    
unsigned long timer = 0; 
int delayTime = 300000;  
bool lightOn = false;   

void setup() {
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP);  
  Serial.begin(9600);                
}

void loop() {
  int pirState = digitalRead(pirPin);    
  int buttonState = digitalRead(buttonPin); 

  if (buttonState == LOW) {
    lightOn = !lightOn;
    digitalWrite(ledPin, lightOn ? HIGH : LOW);
    delay(500); 
  }

  if (Serial.available() > 0) {
    char command = Serial.read();
    if (command == '1') {
      digitalWrite(ledPin, HIGH); 
      lightOn = true;
    }
    if (command == '0') {
      digitalWrite(ledPin, LOW); 
      lightOn = false;
    }
  }

  if (pirState == HIGH && !lightOn) {
    digitalWrite(ledPin, HIGH);
    lightOn = true;
    timer = millis();
  }

  if (lightOn && millis() - timer >= delayTime) {
    for (int i = 0; i < 5; i++) {
      digitalWrite(buzzerPin, HIGH);
      delay(200);
      digitalWrite(buzzerPin, LOW);
      delay(200);
    }
    digitalWrite(ledPin, LOW);  
    lightOn = false;
  }
}

This code initializes the pins for the PIR sensor, LED, buzzer, pushbutton, and Bluetooth module. It reads the state of the PIR sensor and the pushbutton, and controls the LED and buzzer accordingly. The Bluetooth module allows for remote control of the LED.