/********* 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 Control
- Source Code NOT compiled for: Arduino Uno
- Source Code created on: 2024-05-27 15:11:12
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* There are 3 special buttons. This includes a */
/* record button, a play button, and a stop button. */
/* and there are 2 additional buttons to turn on the */
/* LED. These 2 will light up 2 different LEDs each. */
/* When the button is pressed, the LED lights up. But */
/* when */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include
#include
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
void updateOutputs();
/***** DEFINITION OF DIGITAL OUTPUT PINS *****/
const uint8_t but_LED_PIN_D2 = 2;
const uint8_t led1_PIN = 3;
const uint8_t led2_PIN = 4;
const uint8_t record_BUTTON_PIN = 5;
const uint8_t play_BUTTON_PIN = 6;
const uint8_t stop_BUTTON_PIN = 7;
/***** DEFINITION OF OUTPUT RAW VARIABLES *****/
/***** used to store raw data *****/
bool but_LED_PIN_D2_rawData = 0;
/***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
/***** used to store data after characteristic curve transformation *****/
float but_LED_PIN_D2_phyData = 0.0;
/***** INSTANTIATE BUTTON OBJECTS *****/
EasyButton recordButton(record_BUTTON_PIN);
EasyButton playButton(play_BUTTON_PIN);
EasyButton stopButton(stop_BUTTON_PIN);
Bounce ledButton1 = Bounce();
Bounce ledButton2 = Bounce();
void setup(void)
{
// put your setup code here, to run once:
pinMode(but_LED_PIN_D2, OUTPUT);
pinMode(led1_PIN, OUTPUT);
pinMode(led2_PIN, OUTPUT);
// Initialize buttons
recordButton.begin();
playButton.begin();
stopButton.begin();
ledButton1.attach(but_LED_PIN_D2, INPUT_PULLUP);
ledButton1.interval(25); // debounce interval in milliseconds
ledButton2.attach(but_LED_PIN_D2, INPUT_PULLUP);
ledButton2.interval(25); // debounce interval in milliseconds
// Set up button callbacks
recordButton.onPressed([]() {
// Code to handle record button press
});
playButton.onPressed([]() {
// Code to handle play button press
});
stopButton.onPressed([]() {
// Code to handle stop button press
});
}
void loop(void)
{
// put your main code here, to run repeatedly:
recordButton.read();
playButton.read();
stopButton.read();
ledButton1.update();
ledButton2.update();
if (ledButton1.fell()) {
digitalWrite(led1_PIN, HIGH);
}
if (ledButton2.fell()) {
digitalWrite(led2_PIN, HIGH);
}
updateOutputs(); // Refresh output data
}
void updateOutputs()
{
digitalWrite(but_LED_PIN_D2, but_LED_PIN_D2_rawData);
}
/* END CODE */