当前位置:网站首页>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
边栏推荐
- 蓝桥杯单片机省赛第八届
- Class design basis and advanced
- Jetpack's livedata extension mediatorlivedata
- 【IBDFE】基于IBDFE的频域均衡matlab仿真
- Three ways for programmers to learn PHP easily and put chaos out of order
- 蓝桥杯单片机省赛第六届
- 高性能 低功耗Cortex-A53核心板 | i.MX8M Mini
- Qt插件之Qt Designer插件实现
- 5g era is coming in an all-round way, talking about the past and present life of mobile communication
- 一天上手Aurora 8B/10B IP核(5)----从Framing接口的官方例程学起
猜你喜欢

QT designer plug-in implementation of QT plug-in

《MATLAB 神經網絡43個案例分析》:第42章 並行運算與神經網絡——基於CPU/GPU的並行神經網絡運算

蓝桥杯单片机省赛第十一届

滴滴开源DELTA:AI开发者可轻松训练自然语言模型

Which is better, industrial intelligent gateway or edge computing gateway? How to choose the right one?

Interface debugging tool simulates post upload file - apipost

Basic syntax of unity script (6) - specific folder

Pycharm2021 delete the package warehouse list you added

蓝桥杯单片机省赛第十届

【无线图传】基于FPGA的简易无线图像传输系统verilog开发,matlab辅助验证
随机推荐
How about Ping An lifetime cancer insurance?
《动手学深度学习》(二)-- 多层感知机
蓝桥杯单片机第六届温度记录器
蓝桥杯单片机省赛第七届
Jetpack之LiveData扩展MediatorLiveData
高性能 低功耗Cortex-A53核心板 | i.MX8M Mini
蓝桥杯单片机省赛第十二届第二场
高性能 低功耗Cortex-A53核心板 | i.MX8M Mini
Haute performance et faible puissance Cortex - A53 Core Board | i.mx8m mini
《MATLAB 神经网络43个案例分析》:第41章 定制神经网络的实现——神经网络的个性化建模与仿真
MD5 of Oracle
Blue Bridge Cup SCM digital tube skills
Kotlin basic learning 13
Welcome the winter vacation multi school league game 2 partial solution (B, C, D, F, G, H)
Failed to upgrade schema, error: “file does not exist
傅里叶级数
Flutter中深入了解MaterialApp,常用属性解析
蓝桥杯单片机数码管技巧
[Li Kou brush questions] 15 Sum of three numbers (double pointer); 17. Letter combination of phone number (recursive backtracking)
High performance and low power cortex-a53 core board | i.mx8m Mini