/*
LED, Button - example
*/
#include "Button.h"
#define LED1_PIN 13
#define LED2_PIN 12
Button button1(7); // Connect your button between pin 7 and GND
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); // initialize serial interface
Serial.println("LED, Button - example!"); // simple console announcement
button1.begin();
// initialize digital pin LED1_PIN, LED2_PIN, LED_BUILTIN as an output
pinMode(LED1_PIN, OUTPUT);
pinMode(LED2_PIN, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if (button1.pressed()){
Serial.println("Button 1 pressed");
digitalWrite(LED1_PIN, HIGH); // turn the LED on (HIGH is the voltage level)
}
if (button1.released()){
Serial.println("Button 1 released");
digitalWrite(LED1_PIN, LOW); // turn the LED off by making the voltage LOW
}
digitalWrite(LED2_PIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(LED2_PIN, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
}