当前位置:网站首页>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
边栏推荐
- ArcGIS License Server Administrator 无法启动解决方法
- 第2章 Pytorch基础2
- xcode 编译速度慢的解决办法
- ThreadLocal, just look at me!
- 机器学习笔记 一:学习思路
- Mysql database installation and configuration details
- MySQL数据库安装与配置详解
- [point cloud series] a rotation invariant framework for deep point cloud analysis
- [dynamic programming] Yang Hui triangle
- ArcGIS license server administrator cannot start the workaround
猜你喜欢

Component based learning (1) idea and Implementation

给女朋友写个微信双开小工具

Component based learning (3) path and group annotations in arouter

第1章 NumPy基础

【2021年新书推荐】Enterprise Application Development with C# 9 and .NET 5

第3章 Pytorch神经网络工具箱

【点云系列】Neural Opacity Point Cloud(NOPC)

MySQL installation and configuration - detailed tutorial

WebView displays a blank due to a certificate problem

Chapter 4 pytoch data processing toolbox
随机推荐
winform滚动条美化
ArcGIS License Server Administrator 无法启动解决方法
Pytorch模型保存与加载(示例)
What did you do during the internship
.net加载字体时遇到 Failed to decode downloaded font:
【动态规划】最长递增子序列
Fill the network gap
C connection of new world Internet of things cloud platform (simple understanding version)
Easyui combobox 判断输入项是否存在于下拉列表中
[2021 book recommendation] kubernetes in production best practices
【2021年新书推荐】Red Hat Certified Engineer (RHCE) Study Guide
【指标】Precision、Recall
【2021年新书推荐】Red Hat RHCSA 8 Cert Guide: EX200
Handlerthread principle and practical application
深度学习模型压缩与加速技术(一):参数剪枝
第4章 Pytorch数据处理工具箱
Exploration of SendMessage principle of advanced handler
GEE配置本地开发环境
【点云系列】Multi-view Neural Human Rendering (NHR)
【点云系列】Relationship-based Point Cloud Completion