当前位置:网站首页>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
边栏推荐
- The page in H5 shows hidden execution events
- 集成底座方案演示说明
- QT designer plug-in implementation of QT plug-in
- Vite: configure IP access
- Recently, the weather has been extremely hot, so collect the weather data of Beijing, Shanghai, Guangzhou and Shenzhen last year, and make a visual map
- 一天上手Aurora 8B/10B IP核(5)----从Framing接口的官方例程学起
- Oracle 查看被锁的表和解锁
- Fingertips life Chapter 4 modules and packages
- VS2010插件NuGet
- 傅里叶级数
猜你喜欢

《西线无战事》我们才刚开始热爱生活,却不得不对一切开炮

0 foundation how to learn automated testing? Follow these seven steps step by step and you will succeed

Didi open source Delta: AI developers can easily train natural language models

MD5 of Oracle

It took me only 3 months to jump out of the comfort zone and become an automated test engineer for 5 years

Get started with Aurora 8b/10b IP core in one day (5) -- learn from the official routine of framing interface

NLog使用

整理了一份ECS夏日省钱秘籍,这次@老用户快来领走

The first game of the 12th Blue Bridge Cup single chip microcomputer provincial competition
![[mv-3d] - multi view 3D target detection network](/img/aa/741b36ead2dfaa5a165401b8d657b7.jpg)
[mv-3d] - multi view 3D target detection network
随机推荐
Which product of anti-cancer insurance is better?
Class design basis and advanced
What kind of interview is more effective?
Interface debugging tool simulates post upload file - apipost
[Li Kou brush questions] 15 Sum of three numbers (double pointer); 17. Letter combination of phone number (recursive backtracking)
接口调试工具模拟Post上传文件——ApiPost
Oracle 常用SQL
树莓派GPIO引脚控制红绿灯与轰鸣器
Hands on deep learning (II) -- multi layer perceptron
[ibdfe] matlab simulation of frequency domain equalization based on ibdfe
微信小程序中 在xwml 中使用外部引入的 js进行判断计算
高性能 低功耗Cortex-A53核心板 | i.MX8M Mini
蓝桥杯单片机省赛第十一届第一场
"Analysis of 43 cases of MATLAB neural network": Chapter 42 parallel operation and neural network - parallel neural network operation based on cpu/gpu
5G时代全面到来,浅谈移动通信的前世今生
Account management of MySQL
JS generate random numbers
Get started with Aurora 8b/10b IP core in one day (5) -- learn from the official routine of framing interface
SQL Yiwen get window function
Basic syntax of unity script (7) - member variables and instantiation