diff --git a/LED_check.py b/LED_check.py new file mode 100644 index 0000000..5c1f434 --- /dev/null +++ b/LED_check.py @@ -0,0 +1,66 @@ +import RPi.GPIO as GPIO +from uldaq import (get_daq_device_inventory, DaqDevice, AInScanFlag, ScanStatus, + ScanOption, create_float_buffer, InterfaceType, AiInputMode) +from time import time + + +def GPIO_setup(LED1_pin, LED2_pin, Button1_pin, Button2_pin): + # LED output pins + GPIO.setmode(GPIO.BOARD) + + GPIO.setup(LED1_pin, GPIO.OUT) # 1 + GPIO.output(LED1_pin, GPIO.LOW) + GPIO.setup(LED2_pin, GPIO.OUT) # 2 + GPIO.output(LED2_pin, GPIO.LOW) + + LED_status = [False, False] + + # switch controlled input + GPIO.setup(Button1_pin, GPIO.IN) + GPIO.setup(Button2_pin, GPIO.IN) + + return LED_status + + +def main(): + LED1_pin = 11 + LED2_pin = 13 + Button1_pin = 16 + Button2_pin = 18 + + LED_status = GPIO_setup(LED1_pin, LED2_pin, Button1_pin, Button2_pin) + + LED1_t = time() + LED1_t_interval = 2 + + LED2_t = time() + LED2_t_interval = 0.5 + + t0 = time() + + while time() - t0 < 10: + # LED1 blink every 2 sec + if time() - LED1_t < .1 and LED_status[0] == False: + LED_status[0] = True + GPIO.output(LED1_pin, GPIO.HIGH) + if time() - LED1_t >= .1 and LED_status[0] == True: + LED_status[0] = False + GPIO.output(LED1_pin, GPIO.LOW) + + if time() - LED1_t >= LED1_t_interval: + LED1_t = time() + + # LED blink every 0.5 sec + if time() - LED2_t < .1 and LED_status[1] == False: + LED_status[1] = True + GPIO.output(LED2_pin, GPIO.HIGH) + if time() - LED2_t >= .1 and LED_status[1] == True: + LED_status[1] = False + GPIO.output(LED2_pin, GPIO.LOW) + + if time() - LED1_t >= LED1_t_interval: + LED1_t = time() + + +if __name__ == '__main__': + main()