Run at a specific time (Python)

Asked 1 years ago, Updated 1 years ago, 70 views

Raspberry Pi is coding the alarm time with Python, but it's so hard to write a sentence while. Please explain what went wrong

import time

import datetime

from grovepi import*

import math

buzzer_pin =2

button=4

pinMode(buzzer_pin,"OUTPUT")

pinMode(button,"INPUT")



c=int(input("Enter the hour you want to wake up at :"))

d=int(input("Enter the minutes you want to wake up at :"))

b=int(input("Enter the seconds you want to wake up at :"))

now= datetime.datetime.now()



h=now.strftime('%H')

h1=now.strftime('%M')

h2=now.strftime('%S')

while h==c and h1==d and h2>=b:

    h==c and h1==d and h2<=b

    digitalWrite(buzzer_pin,1)

    button_status = digitalRead(button)

    if button_status :  

        digitalWrite(buzzer_pin,0)

time

2022-09-22 08:35

1 Answers

Usually, programs such as the request of the questioner use the scheduler function of the operating system a lot.

unux/linux ramen crontab

Window Scheduler for Windows

Raspberry pie would be Linux, so study crontab.

And I asked you to tell me the wrong thing about the while statement of the code, but there is no explanation such as what you are trying to do or what errors occur, so it is hard to infer what is wrong.


2022-09-22 08:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.