/**
******************************************************************************
* @file : 09_TmVdblMPBttn_1a.ino
* @brief : Example for the ButtonToSwitch library TmVdblMPBttn class
*
* Repository: https://github.com/GabyGold67/ButtonToSwitch_AVR
* WOKWI simulation URL: https://wokwi.com/projects/414261997602105345
*
* Framework: Arduino
* Platform: *
*
* @details The example instantiates a TmVdblMPBttn object using:
* - 1 push button between GND and dmpbMainInpt
* - 1 led with it's corresponding resistor between GND and dmpbIsOnOtpt
* - 1 led with it's corresponding resistor between GND and dmpbVoidedOtpt
*
* This simple example instantiates the TmVdblMPBttn object in the setup(),
* and then checks it's attributes flags through the getters methods in the
* loop().
*
* When a change in the object's outputs attribute flags values is detected, it
* manages the loads and resources that the switch turns On and Off, in this
* example case are the output of some GPIO pins.
*
* @author : Gabriel D. Goldman
* mail <[email protected]>
* Github <https://github.com/GabyGold67>
*
* @date First release: 01/08/2023
* Last update: 07/10/2024 14:20 GMT+0200 DST
******************************************************************************
* @warning **Use of this library is under your own responsibility**
*
* @warning The use of this library falls in the category described by The Alan
* Parsons Project (c) 1980 "Games People play" disclaimer:
* Games people play, you take it or you leave it
* Things that they say aren't alright
* If I promised you the moon and the stars, would you believe it?
*
* Released into the public domain in accordance with "GPL-3.0-or-later" license terms.
******************************************************************************
*/
#include <Arduino.h>
#include <ButtonToSwitch.h>
const uint8_t dmpbMainInpt{A0};
const uint8_t dmpbIsOnOtpt{3};
const uint8_t dmpbVoidedOtpt{8};
TmVdblMPBttn myDMPBttn (dmpbMainInpt, 3000);
void setup() {
digitalWrite(dmpbIsOnOtpt, LOW);
digitalWrite(dmpbVoidedOtpt, LOW);
pinMode(dmpbIsOnOtpt, OUTPUT);
pinMode(dmpbVoidedOtpt, OUTPUT);
myDMPBttn.setStrtDelay(100);
myDMPBttn.begin(20);
}
void loop() {
if(myDMPBttn.getOutputsChange()){
digitalWrite(dmpbIsOnOtpt, (myDMPBttn.getIsOn())?HIGH:LOW);
digitalWrite(dmpbVoidedOtpt, (myDMPBttn.getIsVoided())?HIGH:LOW);
myDMPBttn.setOutputsChange(false);
}
}
On
Voided