“排风扇”的版本间的差异

来自Labplus盛思维基百科
跳转至: 导航搜索
(Tangliufeng移动页面排风扇模块排风扇覆盖重定向)
使用教程
第19行: 第19行:
  
 
== 使用教程 ==
 
== 使用教程 ==
 +
=== Arduino示例 ===
 +
<pre style="color:blue">
 +
int buttonPin =2;   
 +
int fanPin=3;
 +
int val;
 +
void setup() {
 +
  // put your setup code here, to run once:
 +
  Serial.begin(9600);
 +
  pinMode(buttonPin,INPUT);
 +
  pinMode(fanPin,OUTPUT);
 +
}
 +
 +
void loop() {
 +
  val=digitalRead(buttonPin);
 +
  Serial.print(val);
 +
  if(val==HIGH)
 +
  {
 +
    digitalWrite(fanPin,HIGH);
 +
  }
 +
  else
 +
  {
 +
    digitalWrite(fanPin,LOW);
 +
  }
 +
}
 +
</pre>

2018年1月7日 (日) 14:49的版本

黑色传感器最终版12.20-20.png

概述

通过IO引脚输出高低电平控制风扇转动。高电平转动,低电平则否。

技术参数

  • 工作电压:VCC 3.3-5V
  • 模块尺寸:24x46x7.5mm

引脚定义

VCC 电源
NC 空脚
DI 数字输入(高低电平控制风扇)
GND

使用教程

Arduino示例

int buttonPin =2;     
int fanPin=3; 
int val;
void setup() {
  // put your setup code here, to run once:
   Serial.begin(9600);
   pinMode(buttonPin,INPUT);
   pinMode(fanPin,OUTPUT);
}

void loop() {
   val=digitalRead(buttonPin);
   Serial.print(val);
   if(val==HIGH)
   {
     digitalWrite(fanPin,HIGH);
   }
   else
   {
     digitalWrite(fanPin,LOW);
   }
}