当前位置:网站首页>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
边栏推荐
- TypeScript
- SQL time injection
- 使用LinkedHashMap实现一个LRU算法的缓存
- ES6 promise object
- express框架详解
- Composition des mots (sous - total)
- Common regular expression collation
- Solution to the practice set of ladder race LV1 (all)
- Correspondence between STM32 model and contex M
- Wangeditor rich text component - copy available
猜你喜欢
随机推荐
Basic use of pytest
IOT system framework learning
Common regular expression collation
L2-001 emergency rescue (25 points)
mysql实现读写分离
Solution to the practice set of ladder race LV1 (all)
Distribute wxWidgets application
XML文件详解:XML是什么、XML配置文件、XML数据文件、XML文件解析教程
Detailed explanation of express framework
L2-007 family real estate (25 points)
Solution of deleting path variable by mistake
搞笑漫画:程序员的逻辑
电商数据分析--用户行为分析
jS数组+数组方法重构
Pytorch-温度预测
Mtcnn face detection
C语言读取BMP文件
Library function -- (continuous update)
yarn安装与使用
[BSidesCF_2020]Had_a_bad_day