Skip to content

Programmable button

The SODAQ ExpLoRer Rev.5 and higher have a programmable button next to the Bluetooth module.

screenshot

In this example when we push the button the BLUE LED connected to pin 13 will lit.

void setup() {
  // Configure the button as an input and enable the internal pull-up resistor
  pinMode(BUTTON, INPUT_PULLUP);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  // Read the button value into a variable
  int sensorVal = digitalRead(BUTTON);

  // Turn on the LED when the Button is pushed
  if (sensorVal == HIGH) {
    digitalWrite(LED_BUILTIN, LOW);
  } else {
    digitalWrite(LED_BUILTIN, HIGH);
  }
}