Download presentation
Presentation is loading. Please wait.
Published byMarshall Briggs Modified over 6 years ago
1
1 Button 2 Buttons Light Emitting Diodes LED and Buttons
Raspberry Pi Projects 1 Button 2 Buttons Light Emitting Diodes LED and Buttons
2
Simply Button import RPi.GPIO as GPIO import time
GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.IN,pull_up_down=GPIO.PUD_UP) while True: input_state = GPIO.input(17) if input_state == False: print('Thanks MESEF') time.sleep(0.2)
3
2 Buttons from time import sleep import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM) button1=17 button2=12 GPIO.setup(button1,GPIO.IN,pull_up_down=GPIO.PUD_UP) GPIO.setup(button2,GPIO.IN,pull_up_down=GPIO.PUD_UP) while(1): if GPIO.input(button1)==0: print("Button 1 was pressed:") sleep(0.1) if GPIO.input(button2)==0: print("Button 2 was pressed:")
4
Simple LED from gpiozero import LED from time import sleep
led = LED(17) while True: led.on() sleep(2) led.off()
5
Button and LED from time import sleep import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM) button1=17 LED1=21 GPIO.setup(button1,GPIO.IN,pull_up_down=GPIO.PUD_UP) GPIO.setup(LED1,GPIO.OUT) BS1=False while(1): if GPIO.input(button1)==0: print ("Button 1 was pressed") if BS1==False: GPIO.output(LED1,True) BS1=True sleep(0.5) else: GPIO.output(LED1,False)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.