当前位置:网站首页>树莓派开发继电器控制灯
树莓派开发继电器控制灯
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 查看引脚分布和状态

边栏推荐
猜你喜欢

OA项目之我的审批(会议查询&会议签字)

CNN training cycle reconstruction - hyperparametric test | pytorch series (XXVIII)

JS 事件对象2 e.charcode字符码 e.keyCode键码 盒子上下左右移动

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

Es6.--promise, task queue and event cycle

How to simply realize the function of menu dragging and sorting
![[signal denoising] signal denoising based on Kalman filter with matlab code](/img/9e/9e569c83dc3106570cf7571056867f.png)
[signal denoising] signal denoising based on Kalman filter with matlab code

TFX airflow experience

Constant power wireless charging based on stm32

Pytest the best testing framework
随机推荐
Niuke-top101-bm340
[signal denoising] signal denoising based on Kalman filter with matlab code
【OpenGL】GLES20.glClear
数据湖:海量日志采集引擎Flume
Typescript (zero) -- introduction, environment construction, first instance
One month's experience of joining Huawei OD
Note that these regions cannot take the NPDP exam in July
注意,这些地区不能参加7月NPDP考试
Redis AOF log persistence
What "posture" does JD cloud have to promote industrial digitalization to climb to a "new level"?
[brother hero's July training] day 27: picture
【stream】并行流与顺序流
Flutter God operation learning (full level introduction)
Intelligent industrial design software company Tianfu C round financing of hundreds of millions of yuan
数据中台夯实数据基础
Flutter神操作学习之(满级攻略)
使用PyTorch的TensorBoard-可视化深度学习指标 | PyTorch系列(二十五)
数据湖:各模块组件
Confusion matrix in CNN | pytorch series (XXIII)
嵌入式分享合集22