Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Lutfi Hidayati
Published

Smart Home Security with Double Protection System

A door equipped with a motion detection sensor that will send a signal to a microcontroller and activate a dual protection system security

BeginnerFull instructions provided261
Smart Home Security with Double Protection System

Things used in this project

Hardware components

PSoC™ 62S2 Wi-Fi BT Pioneer Kit
Infineon PSoC™ 62S2 Wi-Fi BT Pioneer Kit
×1
Infineon HALL S2GO TLE4964-3M
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Buck Converter LM2596
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Buzzer
Buzzer
×1
9V battery (generic)
9V battery (generic)
×1

Software apps and online services

MicroPython
MicroPython

Hand tools and fabrication machines

Plier, Needle Nose
Plier, Needle Nose
Soldering iron (generic)
Soldering iron (generic)
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

schematic1_mLDHjVXIyB.png

Code

Smart Home Security with Double Protection System

MicroPython
from machine import ADC, Pin
import time
from time import sleep
from machine import PWM
from machine import Pin

buz = Pin("P8_3")   # LED pin for CY8CPROT-062-4343W
buz.init(Pin.OUT)
#buz.on()

adc = ADC(Pin("P10_1"))

#servo
def deg2duty(x):
    return (x - 0) * (8192 - 1638) // (180 - 0) + 1638

pwm = PWM('P9_4', freq=50) # view PWM settings for servo 
print(pwm) 

#pb
pb = Pin('P8_6')
pb.init(Pin.IN) 

while True:
    
    val = adc.read_u16()

    val = adc.read_u16() / 65535
    analogValue = 3.3*val
    print(f"The analog value obtained from connecting to a 3.3V supply is {analogValue}")
    sleep(0.5)
    
    if (analogValue > 1):
        buz.off()
        time.sleep_ms(1000)       
        pwm.duty_u16(deg2duty(90))
        print(pwm.duty_ns())
    else:
        buz.on()
        time.sleep_ms(1000)  
        
    if(pb.value() == 0): #active low
        pwm.duty_u16(deg2duty(0))
        print(pb.value())

Credits

Lutfi Hidayati

Lutfi Hidayati

1 project • 0 followers

Comments