Amaan Javed
Published

Raspberry Pi Good Morning Call

GMC1(GoodMorningCall) works as an alarm clock and you can also set the remainder. in the morning it will wish you and open lights.

IntermediateWork in progress1 hour666
Raspberry Pi Good Morning Call

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Arduino 4 Relays Shield
Arduino 4 Relays Shield
×1
Tactile Switch, Top Actuated
Tactile Switch, Top Actuated
×1
Speaker
×1

Software apps and online services

Raspbian
Raspberry Pi Raspbian

Hand tools and fabrication machines

10 Pc. Jumper Wire Kit, 5 cm Long
10 Pc. Jumper Wire Kit, 5 cm Long

Story

Read more

Code

GMC1

Python
from espeak import espeak
import datetime
from time import sleep
from subprocess import check_call
from gpiozero import MotionSensor,LED,Button

curu = LED(21)#FOR OPEN CURTAINS
cur = LED(20)# FOR CLOSE CURTAINS
li = LED(17)# FOR LIGHTS
button = Button(3)# FOR KILL BUTTON
pir = MotionSensor(4)# FOR PIR

print("Set Morning Alarm: ")
x=int(input("Enter Min(24Hr): "))
y=int(input("Enter Sec(24Hr): "))
print("Set Good Night Call: ")
z=int(input("Enter Sec(24Hr): "))
print("Starting Systems")
sleep(5)
print("Machine Is ON")
espeak.synth(" I am Working")

def shutdown():
    check_call(['sudo', 'poweroff'])

da =  int(datetime.datetime.now().day)
ya = int(datetime.datetime.now().year)
mo = int(datetime.datetime.now().month)
hour = int(datetime.datetime.now().hour)
min = int(datetime.datetime.now().minute)

def wishMe():
    hour = int(datetime.datetime.now().hour)
    if hour>=0 and hour<12:
        espeak.synth("Good Morning Sir, Wake Up")

    elif hour>=12 and hour<18:
        espeak.synth("Good Afternoon Sir")

    else:
        espeak.synth("Good Afternoon Sir")

while True:
    if hour>=x and min==y:
        wishMe()
        strTime = datetime.datetime.now().strftime("%H:%M:%S")
        espeak.synth(f" the time is {strTime}")
        espeak.synth(f"Todays Date Is {da}")
        espeak.synth(mo)
        espeak.synth(ya)
        curu.on()
        sleep(10)
        curu.off
        li.on()
        sleep(60)
    elif pir.when_motion:
        espeak.synth("Welcome Back Sir")
        wishMe()
    elif hour==z and min==5:# NIGHT CALL IT WILL CLOSE CURTAIN AND LIGHTS AND SAY GOOD NIGHT
        espeak.synth("Good Night Sir")
        cur.on()
        sleep(10)
        cur.off()
        li.off()
        sleep(60)
    elif button.wait_for_press():# for kill switch
        espeak.synth("Shutting Down Machine")
        sleep(5)
        shutdown()

Credits

Amaan Javed

Amaan Javed

19 projects • 4 followers
Student

Comments