智能家居基础教程1-初识wifiduino
简介 WiFiduino是使用esp8266作为核心的开发板,相对于传统Arduino控制器,WiFiduin…
/*OJ Button module www.openjumper.cn */ int pushButton = 2; void setup() { Serial.begin(9600); pinMode(pushButton, INPUT_PULLUP); } void loop() { int buttonState = digitalRead(pushButton); Serial.println(buttonState); delay(100); }
红外火焰传感器主要是用来探测周围火焰发出的红外光线,模块输出模拟信号,在灭火机器人比赛中常利用红外火焰传感器检测火源来寻找目标。探测角度大于40度。
工作电压:5V
尺寸:25mm*20mm
工作温度:-25~70℃
探测距离:20~100cm
探测光线波长:940nm
输出信号:模拟信号
S:信号
+:VCC
-:GND
/*OJ flame module www.openjumper.cn */ void setup() { Serial.begin(9600); } void loop() { int sensorValue = analogRead(A0); Serial.println(sensorValue); delay(100); }
Mixly图形化示例程序:
/*
www.openjumper.cn
*/
const int analogInPin = A0;
int sensorValue = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(analogInPin);
Serial.print("sensor = ");
Serial.print(sensorValue);
delay(2);
}
/*
www.openjumper.cn
*/
const int condPin = 2;
const int motorPin = 4;
int condState = 0;
void setup() {
pinMode(motorPin, OUTPUT);
pinMode(condPin, INPUT);
}
void loop() {
condState = digitalRead(condPin);
if (condState == HIGH)
{
digitalWrite(motorPin, HIGH);
}
else
{
digitalWrite(motorPin, LOW);
}
}
/*
www.openjumper.cn
*/
const int slopePin = 2;
const int ledPin = 13;
int slopeState = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(slopePin, INPUT);
}
void loop() {
slopeState = digitalRead(slopePin);
if (slopeState == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}
Mixly图形化示例程序
/*
www.openjumper.cn
*/
const int condPin = 2;
const int ledPin = 13;
int condState = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(condPin, INPUT);
}
void loop() {
condState = digitalRead(condPin);
if (condState == HIGH)
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}
}
Mixly图形化示例程序: