การทดลองเรื่อง ทดสอบการทำการ Interrupt กับบอร์ด NodeMCU ESP-12E
วัตถุประสงค์
1.เพื่อทดสอบการทำการทดสอบการรับสัญญาณ Interrupt ในรูปแบบต่าง ๆ ของบอร์ดพัฒนา NodeMCU ESP-12E
ทดสอบการโดยการเสียบ NodeMCU ลงในเบรดบอร์ด

ทดสอบการ Interrupt ด้วยการเปลี่ยนแปลงสถานะโลจิกจาก 0 เป็น 1 หรือจาก 1 เป็น 0
Interrupt_Change.ino
const byte ledPin = 16; //D0 of Node MCU const byte interruptPin = 5; //D1 of Node MCU volatile byte state = LOW;
void setup() { pinMode(ledPin, OUTPUT); pinMode(interruptPin, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(interruptPin), blink, CHANGE); }
void loop() { digitalWrite(ledPin, state); }
void blink() { state = !state; }
|
Lab10_Interrupt_Falling.ino
const byte ledPin = 16;//D0 of Node MCU const byte interruptPin = 5;//D1 of Node MCU volatile byte state = LOW;
void setup() { pinMode(ledPin, OUTPUT); pinMode(interruptPin, INPUT); attachInterrupt(interruptPin, blink, FALLING); } void loop() { digitalWrite(ledPin, state); } void blink() { state = !state; }
|
Lab10_Interrupt_Rising.ino
const byte ledPin = 16;//D0 of Node MCU const byte interruptPin = 5;//D1 of Node MCU volatile byte state = LOW;
void setup() { pinMode(ledPin, OUTPUT); pinMode(interruptPin, INPUT); attachInterrupt(interruptPin, blink, RISING); } void loop() { digitalWrite(ledPin, state); } void blink() { state = !state; }
|