/********* 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: Button Light
- Source Code compiled for: Arduino Uno
- Source Code created on: 2024-04-19 08:31:17
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* turn on light when button pressed */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include //https://github.com/evert-arias/EasyButton
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
void turnOnLight();
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t button1_PushButton_PIN_D2 = 2;
const uint8_t light_PIN_D3 = 3;
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
EasyButton button1(button1_PushButton_PIN_D2); // Create an instance of the EasyButton class
void setup(void)
{
// put your setup code here, to run once:
pinMode(light_PIN_D3, OUTPUT); // Set the light pin as output
digitalWrite(light_PIN_D3, LOW); // Turn off the light initially
button1.begin(); // Initialize the EasyButton instance
button1.onPressed(turnOnLight); // Call the turnOnLight function when the button is pressed
}
void loop(void)
{
// put your main code here, to run repeatedly:
button1.read(); // Read the button state
// Add any other code you need to run repeatedly here
}
void turnOnLight()
{
// Code to turn on the light
digitalWrite(light_PIN_D3, HIGH);
}