用户工具

站点工具


ocrobot:peripheral_module:button:main

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
ocrobot:peripheral_module:button:main [2018/03/16 09:51] – [参数] 弘毅ocrobot:peripheral_module:button:main [2023/06/07 04:23] (当前版本) – 外部编辑 127.0.0.1
行 1: 行 1:
 +====== 微动开关模块 ======
 +微动开关模块用于输出数字量,按下后输出高电平。
 +===== 特点 =====
 +  * 四个M2.5螺丝孔
 +  * 平面外壳固定设计
 +  * PH2.0防呆接口
 +===== 参数 =====
 +|< 30% 20% 80% >|
 +^  长  |  33.02mm(1300mil)  |
 +^  宽  |  33.02mm(1300mil)  |
 +===== 参考图片 =====
 +===== 示例程序 =====
 +<code cpp>
 +    
 +/*
 +  DigitalReadSerial
 +  读取数字接口D13的输入,并将结果显示在串口监视器
 +*/
 +
 +int pushButton = 13;// 数字口13 连接一个按钮开关,给它命名.
 +
 +void setup() {
 +  Serial.begin(9600); // 初始化串口通讯为9600波特率
 +  pinMode(pushButton, INPUT); // 按键脚作为输入
 +}
 +
 +void loop() {
 +  int buttonState = digitalRead(pushButton); // 读取按钮状态:
 +  Serial.println(buttonState);  // 显示到串口:
 +  delay(1);        // 为了稳定输入状态,使两次读数之间延时1毫秒
 +}
 +</code>
 +