描述
商品內容
§ 按ST188紅外線模組 1個
§ RJ11 6P4C 25cm 信號線 1條
程式範例
// ST188感測器感測到白色 D13 LED 亮, 黑色 D13 LED 暗!
const int st188Pin = 2; // the number of the st188 sensor pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int sensorState = 0; // variable for reading the sensor status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the st188 sensor pin as an input:
pinMode(st188Pin, INPUT);
}
void loop(){
sensorState = digitalRead(st188Pin);
if (sensorState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
接線範例
接線方式如果搭配S4A IO Board只要把電話接頭(RJ11)接到標示D2D3孔位即可完成連接。