/********* Pleasedontcode.com **********
Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- Terms and Conditions:
You have a non-exclusive, revocable, worldwide, royalty-free license
for personal and commercial use. Attribution is optional; modifications
are allowed, but you're responsible for code maintenance. We're not
liable for any loss or damage. For full terms,
please visit pleasedontcode.com/termsandconditions.
- Project: Scanner
- Source Code compiled for: Arduino Uno
- Source Code created on: 2023-10-16 14:54:14
- Source Code generated by: AlexWind
********* Pleasedontcode.com **********/
/****** DEFINITION OF LIBRARIES *****/
#include
#include
/****** SYSTEM REQUIREMENT 1 *****/
// Led turn off and on
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
void toggleLed();
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t button_PushButton_PIN_D2 = 2;
const uint8_t led_PIN_D13 = 13;
// Create an instance of EasyButton
EasyButton button(button_PushButton_PIN_D2);
void setup(void)
{
// put your setup code here, to run once:
pinMode(led_PIN_D13, OUTPUT);
// Initialize the button
button.begin();
// Attach a callback function to the button's onPressed event
button.onPressed(toggleLed);
}
void loop(void)
{
// put your main code here, to run repeatedly:
// Update the button state
button.read();
}
// Callback function to toggle the LED state
void toggleLed()
{
static bool ledState = false;
// Toggle the LED state
ledState = !ledState;
// Set the LED pin based on the new state
digitalWrite(led_PIN_D13, ledState);
}