当前位置:网站首页>Raspberry pie GPIO pin controls traffic light and buzzer
Raspberry pie GPIO pin controls traffic light and buzzer
2022-07-02 03:47:00 【loong_ XL】
Reference resources :
https://blog.csdn.net/weixin_44415639/article/details/114600919
https://blog.csdn.net/chenbo163/article/details/78716269
https://blog.51cto.com/u_11643026/4291142
The programming pin used in this article is the physical engine code BOARD
1、GPIO Control package installation
Reference resources :https://blog.csdn.net/weixin_42078116/article/details/119329032
gpio -v edition 2.52 Talent ,2.50 see gpio readall Output error
It needs to be installed separately :
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
gpio readall
2、 Code control traffic lights and active buzzers
1) traffic lights
GND The pin is used for grounding ,(GND The pin is inserted in 9, Red is inserted in 11; Yellow inserted in 13, Green is inserted in 15)
2) Active buzzer
3 One pin ,GND The pin is used for grounding ,VCC The pin is used to connect 3.3V The power supply ,I/O Pins are used for GPIO Program control buzzer ;(GND The pin is inserted in 39, here VCC Insert corresponding in 17;I/O The pin is inserted in 37)
Active buzzer , Because it is a low level trigger , Initially set to high level GPIO.HIGH Can not sound
#!/usr/bin/python
#coding:utf-8
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
# Initialize the pins , Because it's a low level trigger , Initially set to high level
GPIO.setup(37, GPIO.OUT,initial=GPIO.HIGH) # Buzzer
GPIO.setup(11,GPIO.OUT) # red
GPIO.setup(13,GPIO.OUT) # yellow
GPIO.setup(15,GPIO.OUT) # green
def blink():
# By alternately outputting high and low electric frequencies LED Light flashing
# The red light is on 10s
GPIO.output(11,GPIO.HIGH)
time.sleep(10)
GPIO.output(11,GPIO.LOW)
time.sleep(0.5)
# The yellow light is on 3s
GPIO.output(13,GPIO.HIGH)
time.sleep(3.0)
GPIO.output(13,GPIO.LOW)
time.sleep(0.5)
# The green light is on 10s
GPIO.output(15,GPIO.HIGH)
time.sleep(10)
GPIO.output(15,GPIO.LOW)
time.sleep(0.5)
# The yellow light is on 3s
GPIO.output(13,GPIO.HIGH)
time.sleep(3.0)
GPIO.output(13,GPIO.LOW)
GPIO.output(37,GPIO.LOW)
time.sleep(3.0)
GPIO.output(37,GPIO.HIGH)
# The main program
try:
# Loop execution
while True:
blink()
except KeyboardInterrupt:
pass
GPIO.cleanup()
Raspberry pie traffic lights GPIO
边栏推荐
- 蓝桥杯单片机省赛第九届
- Pycharm2021 delete the package warehouse list you added
- Failed to upgrade schema, error: “file does not exist
- [punch in] flip the string (simple)
- 【IBDFE】基于IBDFE的频域均衡matlab仿真
- In the era of programmers' introspection, five-year-old programmers are afraid to go out for interviews
- A thorough understanding of the development of scorecards - the determination of Y (Vintage analysis, rolling rate analysis, etc.)
- QT designer plug-in implementation of QT plug-in
- 向数据库中存入数组数据,代码出错怎么解决
- VS2010 plug-in nuget
猜你喜欢
《MATLAB 神经网络43个案例分析》:第41章 定制神经网络的实现——神经网络的个性化建模与仿真
Visual slam Lecture 3 -- Lie groups and Lie Algebras
WPViewPDF Delphi 和 .NET 的 PDF 查看组件
接口调试工具模拟Post上传文件——ApiPost
Finally got byte offer. The 25-year-old inexperienced perception of software testing is written to you who are still confused
The 7th Blue Bridge Cup single chip microcomputer provincial competition
Which of PMP and software has the highest gold content?
Basic syntax of unity script (6) - specific folder
《动手学深度学习》(二)-- 多层感知机
NLog use
随机推荐
蓝桥杯单片机省赛第十二届第一场
It took me only 3 months to jump out of the comfort zone and become an automated test engineer for 5 years
MD5 of Oracle
Nacos 配置中心整体设计原理分析(持久化,集群,信息同步)
Pandora IOT development board learning (HAL Library) - Experiment 2 buzzer experiment (learning notes)
一天上手Aurora 8B/10B IP核(5)----从Framing接口的官方例程学起
微信小程序中 在xwml 中使用外部引入的 js进行判断计算
Hands on deep learning (II) -- multi layer perceptron
UI (New ui:: MainWindow) troubleshooting
向数据库中存入数组数据,代码出错怎么解决
Oracle的md5
【力扣刷题】15.三数之和(双指针);17.电话号码的字母组合(递归回溯)
Didi open source Delta: AI developers can easily train natural language models
Class design basis and advanced
PY3 link MySQL
蓝桥杯单片机省赛第十二届第二场
Kotlin basic learning 15
蓝桥杯单片机省赛第十届
[personnel density detection] matlab simulation of personnel density detection based on morphological processing and GRNN network
软件测试人的第一个实战项目:web端(视频教程+文档+用例库)