/********* 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: carracinggame
- Source Code compiled for: Arduino Uno
- Source Code created on: 2023-11-23 04:20:22
- Source Code generated by: jeffrin
********* Pleasedontcode.com **********/
/****** DEFINITION OF LIBRARIES *****/
#include
#include
/****** SYSTEM REQUIREMENT 1 *****/
const uint8_t lightPin = 13; // Pin connected to the light
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t mybutton_PushButton_PIN_D2 = 2;
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
EasyButton myButton(mybutton_PushButton_PIN_D2); // Instance of the EasyButton class
void setup(void)
{
// put your setup code here, to run once:
pinMode(lightPin, OUTPUT); // Set the light pin as output
pinMode(mybutton_PushButton_PIN_D2, INPUT_PULLUP);
myButton.begin(); // Initialize the button
}
void loop(void)
{
// put your main code here, to run repeatedly:
myButton.read(); // Read the button state
// Check if the button is pressed
if (myButton.isPressed()) {
// Turn off the light
digitalWrite(lightPin, LOW);
} else {
// Turn on the light
digitalWrite(lightPin, HIGH);
}
}