   // Compare them - state records inverse of switch read
   if (value == state) { // Equal means a change
     // Update values as needed, if needed
-    value = not state;
-    digitalWrite(ledPin, value);
+    state = not value;
+    digitalWrite(ledPin, state);
   }
 }
 

 by Tom Igoe
 modified 03 May 2016
 by @JDWarner
 */

// constants won't change. They're used here to
// set pin numbers:
const int keyPin = 2;          // pin connected to organ key
const int ledPin =  LED_BUILTIN;  // the number of the LED pin
bool keyState = false;    // the key state, starts off
bool keyRead = false;     // input from digital pin



 Turns on and off a light emitting diode(LED) connected to digital
 pin 13, when pressing a key attached to pin 2.

 The circuit:
 * LED built in to pin 13, connected to ground
