当前位置:网站首页>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
边栏推荐
- 机器学习——朴素贝叶斯
- 【2021年新书推荐】Professional Azure SQL Managed Database Administration
- Miscellaneous learning
- 【2021年新书推荐】Red Hat Certified Engineer (RHCE) Study Guide
- [dynamic programming] different paths 2
- Chapter 4 pytoch data processing toolbox
- [2021 book recommendation] kubernetes in production best practices
- MySQL的安装与配置——详细教程
- Face_ Recognition face detection
- Machine learning III: classification prediction based on logistic regression
猜你喜欢

Binder mechanism principle

Use originpro express for free
Raspberry Pie: two color LED lamp experiment

Record WebView shows another empty pit

【点云系列】Neural Opacity Point Cloud(NOPC)
![[recommendation of new books in 2021] practical IOT hacking](/img/9a/13ea1e7df14a53088d4777d21ab1f6.png)
[recommendation of new books in 2021] practical IOT hacking

微信小程序 使用wxml2canvas插件生成图片部分问题记录
![[2021 book recommendation] practical node red programming](/img/f4/e397c01f1551cd6c59ea4f54c197e6.png)
[2021 book recommendation] practical node red programming

【点云系列】Relationship-based Point Cloud Completion
![[point cloud series] sg-gan: advantageous self attention GCN for point cloud topological parts generation](/img/1d/92aa044130d8bd86b9ea6c57dc8305.png)
[point cloud series] sg-gan: advantageous self attention GCN for point cloud topological parts generation
随机推荐
MySQL installation and configuration - detailed tutorial
[recommendation of new books in 2021] practical IOT hacking
【点云系列】FoldingNet:Point Cloud Auto encoder via Deep Grid Deformation
face_recognition人脸检测
Visual Studio 2019安装与使用
Computer shutdown program
【点云系列】Relationship-based Point Cloud Completion
C language, a number guessing game
Machine learning II: logistic regression classification based on Iris data set
【动态规划】最长递增子序列
[2021 book recommendation] Red Hat Certified Engineer (RHCE) Study Guide
Face_ Recognition face detection
Chapter 8 generative deep learning
【2021年新书推荐】Kubernetes in Production Best Practices
树莓派:双色LED灯实验
ArcGIS license server administrator cannot start the workaround
Pytorch best practices and coding style guide
【2021年新书推荐】Effortless App Development with Oracle Visual Builder
电脑关机程序
[dynamic programming] triangle minimum path sum