#include <Toggle.h>
// Variables that remain constant
const byte pinSwitch = 8; // My volupPin
const byte pinLED1 = 2; // My yellow LED
const byte pinLED2 = 13; // Inbuilt LED
// Variables that can change
byte LED1state = LOW;
byte LED2state = LOW;
byte code = 0;
Toggle sw(pinSwitch);
void setup ()
{
Serial.begin(115200);
Serial.println(F("ToggleLibrary-Toggle_2_LEDs-e1"));
sw.begin(pinSwitch);
pinMode(pinLED1, OUTPUT);
pinMode(pinLED2, OUTPUT);
}
void loop ()
{
sw.poll();
code = sw.pressCode();
if (code == 0xF1)
{
LED1state = !LED1state;
digitalWrite(pinLED1, LED1state);
}
else if (code == 0x10)
{
LED2state = !LED2state;
}
Serial.print("code = ");
Serial.println(code);
delay(500);
}