initial commit
This commit is contained in:
commit
ad49985a12
1 changed files with 21 additions and 0 deletions
21
main.py
Normal file
21
main.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import RPi.GPIO as GPIO
|
||||
import time
|
||||
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
|
||||
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
||||
GPIO.setup(24, GPIO.OUT)
|
||||
|
||||
try:
|
||||
while True:
|
||||
button_state = GPIO.input(23)
|
||||
if button_state == False:
|
||||
GPIO.output(24, True)
|
||||
print('Button Pressed...')
|
||||
time.sleep(0.2)
|
||||
else:
|
||||
GPIO.output(24, False)
|
||||
except:
|
||||
GPIO.cleanup()
|
Loading…
Reference in a new issue