Hallo! I´m trying to make a simple program: When i press a button, spark starts blinking a LED (D2) each second, and when pressed again, it stops blinking.
Problem is, during the delay() Spark stops reading the button. I also tryed using detatchInterrupt() but it doesn´t even compiles 
const int buttonPin = D1; // the number of the pushbutton pin
const int ledPin = D2; // the number of the LED pin
volatile bool buttonPressed = false;
volatile bool turnOnTheLight = false;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLDOWN); // sets pin as input
Serial.begin(9600); // Open serial over USB.
}
void loop(){
if(digitalRead(buttonPin) == HIGH) buttonDown();
if(digitalRead(buttonPin) == LOW) buttonUp();
if (turnOnTheLight) light();
}
void light() {
digitalWrite(ledPin, HIGH); // Turn ON the LED pins
delay(1000);
digitalWrite(ledPin, LOW); // Turn OFF the LED pins
delay(1000);
}
void buttonDown() {
if (!buttonPressed) {
Serial.print("buttonDown!");
buttonPressed = true;
}
digitalWrite(D7, HIGH);
}
void buttonUp() {
if (buttonPressed) {
Serial.print("buttonUp!");
if (!turnOnTheLight) turnOnTheLight=true;
else turnOnTheLight = false;
}
buttonPressed = false;
digitalWrite(D7, LOW);
}