// just the button thing

byte buttonState;

const byte buttonPin = 10;
const int buttonInterval = 25;

void setup() {
  Serial.begin(115200);
  Serial.println("Starting kerstboomprog.ino");
  Serial.print("buttonState = ");
  Serial.println(buttonState);

  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  readButton();   // 

  digitalWrite(LED_BUILTIN, buttonState);
}

//checks for button
void readButton()
{
  static byte previousButton = HIGH;
  static unsigned long previousButtonMillis = 0;

  unsigned long now = millis();

  if (now - previousButtonMillis < buttonInterval)
    return;   // too soon to look at the button again

  byte currentButton = digitalRead(buttonPin);
  if (currentButton != previousButton) {
    previousButtonMillis = now;
    previousButton = currentButton;

    if(currentButton) {
      buttonState = !buttonState;
      Serial.print ("buttonState = ");
      Serial.println (buttonState);
    }
  }
}