当前位置:网站首页>Infrared sensor control switch
Infrared sensor control switch
2022-04-23 07:22:00 【Lin Jinpeng】
One 、 Results the preview
Infrared sensor control switch
Two 、 Implementation process
# -*- coding: utf-8 -*-
import RPi.GPIO as GPIO
# Use actual physical pins to GPIO mouth
GPIO.setmode(GPIO.BOARD)
# Set the pin to input mode , Pull up to high level (3.3V)
GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# LED Pin settings
# Set up Pin The mode is output mode
GPIO.setup(12, GPIO.OUT)
# Set up Pin The pin is low level (0V) close LED
GPIO.output(12, GPIO.LOW)
# Set the frequency to 2KHz
Led = GPIO.PWM(12, 2000)
Led.start(0)
# Infinite loop
def loop():
while True:
if (0 == GPIO.input(11)):
# Appear barrier , Light up
Led.ChangeDutyCycle(100.0)
else:
# Remove barriers , Turn off the lights
Led.start(0)
# Program entrance
if __name__ == '__main__':
try:
# Infinite loop
loop()
# When pressed Ctrl+C when , Will perform destroy() Subroutines
except KeyboardInterrupt:
# Call to release resources
GPIO.cleanup()
版权声明
本文为[Lin Jinpeng]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230609472992.html
边栏推荐
- MySQL的安装与配置——详细教程
- Thanos.sh灭霸脚本,轻松随机删除系统一半的文件
- Mysql database installation and configuration details
- winform滚动条美化
- PyTorch最佳实践和代码编写风格指南
- [2021 book recommendation] kubernetes in production best practices
- MySQL5. 7 insert Chinese data and report an error: ` incorrect string value: '\ xb8 \ XDF \ AE \ xf9 \ X80 at row 1`
- C# EF mysql更新datetime字段报错Modifying a column with the ‘Identity‘ pattern is not supported
- [dynamic programming] longest increasing subsequence
- MySQL notes 3_ Restraint_ Primary key constraint
猜你喜欢
免费使用OriginPro学习版
Visual Studio 2019安装与使用
Google AdMob advertising learning
【2021年新书推荐】Practical Node-RED Programming
[point cloud series] sg-gan: advantageous self attention GCN for point cloud topological parts generation
【点云系列】FoldingNet:Point Cloud Auto encoder via Deep Grid Deformation
c语言编写一个猜数字游戏编写
【点云系列】Neural Opacity Point Cloud(NOPC)
WebView displays a blank due to a certificate problem
Chapter 8 generative deep learning
随机推荐
Markdown basic grammar notes
机器学习——朴素贝叶斯
Exploration of SendMessage principle of advanced handler
Reading notes - activity
[3D shape reconstruction series] implicit functions in feature space for 3D shape reconstruction and completion
Mysql database installation and configuration details
【点云系列】DeepMapping: Unsupervised Map Estimation From Multiple Point Clouds
cmder中文乱码问题
第2章 Pytorch基础1
机器学习 二:基于鸢尾花(iris)数据集的逻辑回归分类
Miscellaneous learning
Data class of kotlin journey
1.2 preliminary pytorch neural network
Chapter 2 pytoch foundation 1
【2021年新书推荐】Learn WinUI 3.0
ArcGIS License Server Administrator 无法启动解决方法
Android interview Online Economic encyclopedia [constantly updating...]
torch_ Geometric learning 1, messagepassing
face_recognition人脸检测
PyTorch中的一些常见数据类型转换方法,与list和np.ndarray的转换方法