- DN6851(パナソニック社製)
を利用しました。耐用電圧の幅が広いので、直接つなげてもOKなようです(たぶん)。Arduinoとの接続には、割り込み処理をするために2番ピンに繋げてます。以下、スケッチです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void chk () { | |
if (digitalRead(2) == LOW) { | |
Serial.println("low"); | |
} else { | |
Serial.println("high"); | |
} | |
} | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(9800); | |
attachInterrupt(0, chk, CHANGE); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
} |
0 件のコメント:
コメントを投稿