Assignment_1_commit

This commit is contained in:
SKT-Sukatat 2023-10-11 11:45:03 +07:00
commit 138f84efb6
1 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,37 @@
import RPi.GPIO as GPIO
import time
PIR_pin = 3
LED_pin = 4
GPIO.setmode(GPIO.BOARD)
GPIO.setup(LED_pin ,GPIO.OUT) # Set up pin to emit LED
GPIO.setwarnings(False)
GPIO.setup(PIR_pin, pull_up_down = GPIO.PUD_UP) # Set up pin 23 pull up
'''
def PIN_pin_ISR(pressed):
print("Falling Edge Detected")
'''
def Blink_3_times(pressed):
i = 0
while(i<=2):
GPIO.output(LED_pin, GPIO_HIGH)
time.sleep(1)
GPIO.output(LED_pin, GPIO_LOW)
time.sleep(1)
print("LED Blink")
GPIO.add_event_detect(PIR_PIN, GPIO.FALLING, callback = Blink_3_times, bouncetime = 300)
try:
while(1):
print("Nothing")
time.sleep(1)
except:
GPIO.cleanup()