so im trying to make a program for when i push a button the led will stay on, and when i push it again the button will go off. ive tried to fix it but i keep getting this error
Arduino: 1.6.7 (Windows 7), Board: "Arduino/Genuino Uno"
C:\Users\Aaron\Desktop\demo\LED_button\LED_button.ino: In function 'void loop()':
LED_button:16: error: 'ledOn' was not declared in this scope
ledOn = !ledOn;
^
LED_button:23: error: 'ledOn' was not declared in this scope
digitalWrite(ledPin, ledOn);
^
exit status 1
'ledOn' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
ALSO here is my code
int switchPin = 8;
int ledPin = 13;
boolean lastButton = LOW;
boolean leadOn = false;
void setup()
{
pinMode(switchPin,INPUT);
pinMode(ledPin, OUTPUT);
}
void loop()
{
if (digitalRead(switchPin) == HIGH && lastButton == LOW)
{
ledOn = !ledOn;
lastButton = HIGH;
}
else
{
lastButton = digitalRead(switchPin);
}
digitalWrite(ledPin, ledOn);
}