title: Arduino AttachInterrupt() seems to run twice
body: <p>I got some code from a student of mine who has recently started with arduino.</p>
  
  <p>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.</p>
  
  <p>I've tried to find answers but I couldn't find any, so here I am.</p>
  
  <p>Please help me.</p>
  
  <pre><code>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 ;
  
  
  }
  </code></pre>