当前位置:网站首页>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
边栏推荐
- Pytorch实现简单线性回归Demo
- PyTorch四种常用优化器测试
- Composition des mots (sous - total)
- {one week summary} take you into the ocean of JS knowledge
- About string immutability
- [Bluebridge cup 2020 preliminary] horizontal segmentation
- 5G工作原理详解(解释&图解)
- [Kerberos] deeply understand the Kerberos ticket life cycle
- error C4996: ‘strcpy‘: This function or variable may be unsafe. Consider using strcpy_ s instead
- 电商数据分析--用户行为分析
猜你喜欢
Word typesetting (subtotal)
MySQL and C language connection (vs2019 version)
2019 Tencent summer intern formal written examination
FTP文件上传文件实现,定时扫描文件夹上传指定格式文件文件到服务器,C语言实现FTP文件上传详解及代码案例实现
Vs2019 first MFC Application
机器学习--决策树(sklearn)
快来走进JVM吧
Kaggle竞赛-Two Sigma Connect: Rental Listing Inquiries
Principle and implementation of MySQL master-slave replication
Integration test practice (1) theoretical basis
随机推荐
{one week summary} take you into the ocean of JS knowledge
sklearn之feature_extraction.text.CountVectorizer / TfidVectorizer
List and set
2020 WANGDING cup_ Rosefinch formation_ Web_ nmap
error C4996: ‘strcpy‘: This function or variable may be unsafe. Consider using strcpy_ s instead
Reading BMP file with C language
E-commerce data analysis -- User Behavior Analysis
Nodejs connect mysql
encoderMapReduce 随手记
分布式节点免密登录
天梯赛练习集题解LV1(all)
MATLAB学习和实战 随手记
STM32 如何定位导致发生 hard fault 的代码段
Connexion sans mot de passe du noeud distribué
小L的试卷
ToggleButton实现一个开关灯的效果
jS数组+数组方法重构
Word排版(小计)
机器学习--线性回归(sklearn)
Software I2C based on Hal Library