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

来自Labplus盛思维基百科
跳转至: 导航搜索
图形化示例
使用教程
 
(未显示2个用户的5个中间版本)
第19行: 第19行:
  
 
== 使用教程 ==
 
== 使用教程 ==
=== MicroPython示例 ===
+
=== <font size="3">掌控板</font> ===
 +
{|
 +
|-
 +
| [[文件:风扇.png |900px|居中|无框]]
 +
|}
 +
 
 +
=== Arduino示例 ===
 
<pre style="color:blue">
 
<pre style="color:blue">
//程序功能:如果按键按下打开排风扇,否则关闭//
+
//程序功能:按键按下,风扇转动;按键松开,风扇停止//
from microbit import *
+
int buttonPin =2;   
 
+
int fanPin=3;
def digitalRead(pin):
+
int val;
  pin.read_digital()
+
void setup() {
  pin.set_pull(pin.NO_PULL)
+
  // put your setup code here, to run once:
  return pin.read_digital()
+
  Serial.begin(9600);
 +
  pinMode(buttonPin,INPUT);
 +
  pinMode(fanPin,OUTPUT);
 +
}
  
 
+
void loop() {
while True:
+
  val=digitalRead(buttonPin);
  if digitalRead(pin2):
+
  Serial.print(val);
    pin0.write_digital(1)
+
  if(val==HIGH)
  else:
+
  {
    pin0.write_digital(0)
+
    digitalWrite(fanPin,HIGH);
 +
  }
 +
  else
 +
  {
 +
    digitalWrite(fanPin,LOW);
 +
  }
 +
}
 
</pre>
 
</pre>
 
 
  
 
=== 图形化示例 ===
 
=== 图形化示例 ===
<br/><br/>
+
程序功能:当按下按键的时候,风扇转动;否则,风扇停止
 
+
{|
:::{|
 
 
|-
 
|-
| [[文件:排风扇 (2).png|600px|center|无框]]
+
|[[文件:风扇 1.png|900px|无框|]]
 
|}
 
|}
  

2020年6月30日 (二) 16:48的最新版本

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

概述

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

技术参数

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

引脚定义

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

使用教程

掌控板

风扇.png

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);
   }
}

图形化示例

程序功能:当按下按键的时候,风扇转动;否则,风扇停止

风扇 1.png

版本历史记录

Version Date Note [+]新增[-]删除[^]修复
V2.0