Hi There! I am using this sketch to read the pin change status on 13th pin on UNO and fire the serial message only when there is a change. I believe the better way is to use the interrupts. I have gone through some examples, but most of the examples talks about the pin changes on pins 2 and 3 (Interrupts 0 & 1). I am new to interrupts. Not sure if this sketch can be achieved through interrupts? if some one can shed some light and provide an example with interrupts that would be great. I want to read the pin status of pin 13th and send a serial msg when there is a change in status.
Thanks in Advance
boolean statusCheck=false;
#include <SoftwareSerial.h>
void setup()
{
Serial.begin(9600);
}
void loop()
{
if((digitalRead(13)==HIGH) && (statusCheck==false))
{
statusCheck = true;
Serial.println("LED is ON");
}
else
if((digitalRead(13)==LOW) && (statusCheck == true))
{
Serial.println("LED is OFF");
statusCheck = false;
}
}