I got some code from a student of mine who has recently started with arduino.
He tried to do an Interrupt and it sort of worked. The thing was that it ran twice (the function he called) so the booleans were reset.
I've tried to find answers but I couldn't find any, so here I am.
Please help me.
boolean state = 1 ;
void setup()
{
pinMode (2 , INPUT);
pinMode (8 , OUTPUT);
Serial.begin(38400);
attachInterrupt( 0 , ngt, RISING);
}
void loop()
{
Serial.println (digitalRead(2));
digitalWrite ( 8 , state );
delay(50);
}
void ngt()
{
state = !state ;
}