当前位置:网站首页>Raspberry pie tap switch button to use
Raspberry pie tap switch button to use
2022-07-06 11:54:00 【Forgotten world】
Please add group for problem consultation and project source code download :
Group name :IT Project communication group
Group number :245022761
2、 Use raspberry pie to design a simple key control LED Light on system . Read the external digital signal through the raspberry pie controller , Use three buttons to control three colors LED The lamp , When a key is pressed, the corresponding LED The light will light up , After the key is released, the corresponding LED The light goes out . Press one of the three keys , You can see the corresponding one LED The light will light up ; When pressing two buttons at the same time , Two corresponding LED The light will come on ; When you press three keys at the same time, there are three LED The lights are on at the same time . Complete the hardware connection circuit design of the control system , Draw the system hardware principle block diagram and program flow chart , Programming , The system has passed the joint commissioning and has been summarized and analyzed .
import RPi.GPIO import time yellow=0 red=5 green=6 button1=13 button2=19 button3=26 RPi.GPIO.setmode(RPi.GPIO.BCM) RPi.GPIO.setup(red,RPi.GPIO.OUT) RPi.GPIO.setup(green,RPi.GPIO.OUT) RPi.GPIO.setup(yellow,RPi.GPIO.OUT) RPi.GPIO.setup(button1, RPi.GPIO.IN, pull_up_down=RPi.GPIO.PUD_UP) RPi.GPIO.setup(button2, RPi.GPIO.IN, pull_up_down=RPi.GPIO.PUD_UP) RPi.GPIO.setup(button3, RPi.GPIO.IN, pull_up_down=RPi.GPIO.PUD_UP) try: RPi.GPIO.output(red,1) RPi.GPIO.output(green,1) RPi.GPIO.output(yellow,1) while True: time.sleep(0.06) if RPi.GPIO.input(button1) == 0: RPi.GPIO.output(red,1) else: RPi.GPIO.output(red,0) if RPi.GPIO.input(button2) == 0: RPi.GPIO.output(green,1) else: RPi.GPIO.output(green,0) if RPi.GPIO.input(button3) == 0: RPi.GPIO.output(yellow, 1) else: RPi.GPIO.output(yellow, 0) except KeyboardInterrupt: pass
边栏推荐
猜你喜欢
随机推荐
[CDH] modify the default port 7180 of cloudera manager in cdh/cdp environment
Reading notes of difficult career creation
Detailed explanation of nodejs
yarn安装与使用
Kaggle竞赛-Two Sigma Connect: Rental Listing Inquiries(XGBoost)
Encodermappreduce notes
5G工作原理详解(解释&图解)
Détails du Protocole Internet
MySQL and C language connection (vs2019 version)
Basic use of pytest
2019 Tencent summer intern formal written examination
小L的试卷
MongoDB
Word排版(小計)
L2-001 emergency rescue (25 points)
Correspondence between STM32 model and contex M
SQL时间注入
機器學習--線性回歸(sklearn)
PyTorch四种常用优化器测试
TypeScript