From 138f84efb68c6319cb3016c944a4769dcbe4816a Mon Sep 17 00:00:00 2001 From: SKT-Sukatat <82657530+SKT-Sukatat@users.noreply.github.com> Date: Wed, 11 Oct 2023 11:45:03 +0700 Subject: [PATCH] Assignment_1_commit --- Assignment 1/assignment_1.py | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Assignment 1/assignment_1.py diff --git a/Assignment 1/assignment_1.py b/Assignment 1/assignment_1.py new file mode 100644 index 0000000..46baedf --- /dev/null +++ b/Assignment 1/assignment_1.py @@ -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() + \ No newline at end of file