Security System

The Security System project is a simple yet useful real-life scenario application. It uses a Ultrasonic Distance Sensor Module, the Buzzer Module and the RGB LED Module to work like a geniune security system. The system is designed to be activated when there is a movement in designated area.

About Tools and Materials:

SMD Red (Robot Shop)

SMD USB Gateway (Robot Shop)

Ultrasonic Distance Sensor Module (Robot Shop)

Buzzer Module (Robot Shop)

RGB LED Module (Robot Shop)

Step 1: Hardware & Software Overview

Project Key Components

  1. SMD

    The SMD acts as a bridge between the script and the modules. It is responsible for interpreting the commands sent by the script and translating them into actions that read input from the Ultrasonic Distance Sensor Module and actuate the visual and audible warning signals.

  2. Ultrasonic Distance Sensor Module

    The Ultrasonic Distance Sensor Module measures the distance between the sensor and an object in its path. It provides distance data to the script for security monitoring.

  3. Buzzer Module

    The Buzzer Module serves as the audible warning. It emits sound when activated when there is an object in the designated area.

  4. RGB LED Module

    The RGB LED Module is used to provide visual warning. It can emit different colors and light intensities as programmed.

  5. SMD Libraries

    The SMD library is at the heart of the application. It communicates with the SMD using a specific communication protocol, sending commands to read the Ultrasonic Distance Sensor Module and actuate the visual and audible warnings, the RGB LED Module and the Buzzer Module.

Project Key Features

  • Distance-based Security Monitoring

    The Security System continuously monitors the distance measured by the Ultrasonic Distance Sensor Module. If the distance of the detected object is equal or closer than the determined distance value, the alert system will be activated.

  • Visual Feedback with the RGB LED Module

    The RGB LED Module displays red and blue lights to indicate the security status. Red lights may represent an alert or danger, while blue lights indicate a normal or safe condition.

  • Audible Feedback with the Buzzer Module

    The Buzzer Module emits a sound when the system detects a potential security threat, providing an audible alert to draw attention to the situation.

Step 2: Assemble

Getting Started

  1. Hardware Setup

Project Wiring Diagram

Step 3: Run & Test

  1. Run the Application

    • Execute the script, initiating the Security System application.

    • Observe the RGB LED Module displaying colors and the Buzzer Module emitting sound based on the detected distance.

  2. Customize Security Thresholds

    • Adjust the predetermined distance threshold in the script to customize the security monitoring levels.

    • Experiment with different colors and sound patterns for the LED and buzzer to suit specific security scenarios.

Project Codes

from smd.red import*
import time
from serial.tools.list_ports import comports
from platform import system

def USB_Port():
	ports = list(comports())
	usb_names = {
		"Windows": ["USB Serial Port"],
		"Linux": ["/dev/ttyUSB"],
		"Darwin": [
			"/dev/tty.usbserial",
			"/dev/tty.usbmodem",
			"/dev/tty.SLAB_USBtoUART",
			"/dev/tty.wchusbserial",
			"/dev/cu.usbserial",
            		"/dev/cu.usbmodem",
			"/dev/cu.SLAB_USBtoUART",
			"/dev/cu.wchusbserial",
		]
	}
	
	os_name = system()
	if ports:
		for port, desc, hwid in sorted(ports):
			if any(name in port or name in desc for name in usb_names.get(os_name, [])):
				return port
		print("Current ports:")
		for port, desc, hwid in ports:
			print(f"Port: {port}, Description: {desc}, Hardware ID: {hwid}")
	else:
		print("No port found")
	return None
	
port = USB_Port()
m = Master(port)
m.attach(Red(0))

m.scan_modules(0)



while True:
    distance = m.get_distance(0, 1)
    print(distance)
    if distance != None:
        if distance < 15:
            m.set_buzzer(0, 1, 600)
            m.set_rgb(0, 1, red = 255, green = 0, blue = 0)
            time.sleep(0.5)
            m.set_rgb(0, 1, red = 0, green = 0, blue = 255)

        else:
            m.set_buzzer(0, 1, 0)
            m.set_rgb(0, 1, red = 0, green = 0, blue = 0)
            m.set_buzzer(0, 1, 0)

Last updated