当前位置:网站首页>树莓派开发继电器控制灯
树莓派开发继电器控制灯
2022-07-28 02:12:00 【十年哞一剑】
继电器接线

继电器原理 :给一个高电平 NO--->COM 否则 NO---X---COM
树莓派io图

继电器的 com和vcc 接3.3 就行了
保证模块接入的电源是一样的
代码
#include <stdio.h>
#include <wiringPi.h>
#define INOUT GPIO 7
int main()
{
int cmd;
/*初始化判断*/
if (wiringPiSetup()==-1){
printf("初始失败!n"):
return -2;
}
/*模式选择*/
pinMode (INOUT GPIO,OUTPUT);
/*输出置高不吸合*/
digitalWrite(INOUT GPIO,HIGH);
while(1){
printf("0断>>>><く<1通\n")
scanf("号d",&cmd);
getchar();//完成一次输出最后换行
/*获取到1吸合*/
if (cmd==1){
digitalWrite (INOUT GPIO,LOW);
}
/*获取到0不吸合*/
else if (cmd==0){
digitalwrite(INOUT GPIO,HIGH);
}
/*什么都没有返回-1*/
else return -1;
}
return 0;
}

从键盘 获取 到 0 克隆 ssh 页面 查看 输出的状态
获取到0 输出1
gpio raedall 查看引脚分布和状态

边栏推荐
- Redis群集
- Canvas from getting started to persuading friends to give up (graphic version)
- Center-based 3D Object Detection and Tracking(基于中心的3D目标检测和跟踪 / CenterPoint)论文笔记
- Vscode debug displays multiple columns of data
- [QNX Hypervisor 2.2用户手册]9.10 pass
- Confusion matrix in CNN | pytorch series (XXIII)
- 【红队】ATT&CK - 文件隐藏
- 43.js -- scope chain
- 注意,这些地区不能参加7月NPDP考试
- 为什么登录时,明明使用的是数据库里已经有的账号信息,但依旧显示“用户不存在”?
猜你喜欢

JS event object offsetx/y clientx y pagex y

Why is it that when logging in, you clearly use the account information already in the database, but still display "user does not exist"?

为什么登录时,明明使用的是数据库里已经有的账号信息,但依旧显示“用户不存在”?

Explanation of CNN circular training | pytorch series (XXII)

Is it you who are not suitable for learning programming?

Unexpected harvest of epic distributed resources, from basic to advanced are full of dry goods, big guys are strong!

分布式事务——Senta(一)

Retainface use error: modulenotfounderror: no module named'rcnn.cyton.bbox'

行业洞察 | 语音识别真的超过人耳朵了吗?

Record of a cross domain problem
随机推荐
一次跨域问题的记录
ORACLE BASICFILE LOB字段空间回收SHRINK SPACE的疑惑
JS event object 2 e.charcode character code e.keycode key code box moves up, down, left and right
为什么登录时,明明使用的是数据库里已经有的账号信息,但依旧显示“用户不存在”?
“29岁,普通功能测试,我是如何在一周内拿到5份Offer的?”
Explanation of CNN circular training | pytorch series (XXII)
Vscode debug displays multiple columns of data
Arm32 for remote debugging
智能工业设计软件公司天洑C轮数亿元融资
[brother hero's July training] day 26: check the collection
How to simply realize the function of menu dragging and sorting
没法预测明天的涨跌
style=“width: ___“ VS width=“___“
MySQL essay
使用PyTorch的TensorBoard-可视化深度学习指标 | PyTorch系列(二十五)
Distributed transaction Senta (I)
43.js -- scope chain
WEB安全基础 - - -命令执行漏洞
蓝桥杯原题
P6118 [JOI 2019 Final]珍しい都市 题解