当前位置:网站首页>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
边栏推荐
- sklearn之feature_extraction.text.CountVectorizer / TfidVectorizer
- Password free login of distributed nodes
- PyTorch四种常用优化器测试
- Connexion sans mot de passe du noeud distribué
- 第4阶段 Mysql数据库
- MongoDB
- [Blue Bridge Cup 2017 preliminary] grid division
- [BSidesCF_2020]Had_a_bad_day
- [CDH] cdh5.16 configuring the setting of yarn task centralized allocation does not take effect
- STM32 如何定位导致发生 hard fault 的代码段
猜你喜欢

【CDH】CDH5.16 配置 yarn 任务集中分配设置不生效问题

保姆级出题教程

Apprentissage automatique - - régression linéaire (sklearn)

IOT system framework learning

FTP file upload file implementation, regularly scan folders to upload files in the specified format to the server, C language to realize FTP file upload details and code case implementation

分布式節點免密登錄

数据分析之缺失值填充(重点讲解多重插值法Miceforest)

Vs2019 desktop app quick start

B tree and b+ tree of MySQL index implementation
C语言读取BMP文件
随机推荐
Password free login of distributed nodes
MTCNN人脸检测
[yarn] CDP cluster yarn configuration capacity scheduler batch allocation
TypeScript
Internet protocol details
MySQL主从复制的原理以及实现
Redis面试题
[Flink] cdh/cdp Flink on Yan log configuration
L2-001 emergency rescue (25 points)
wangeditor富文本组件-复制可用
保姆级出题教程
Some concepts often asked in database interview
牛客Novice月赛40
常用正则表达式整理
Wangeditor rich text component - copy available
[BSidesCF_2020]Had_ a_ bad_ day
【presto】presto 参数配置优化
Word排版(小计)
树莓派 轻触开关 按键使用
5G工作原理详解(解释&图解)