CCCPaste

Button Control rev_01

/********* 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 compiled for: Arduino Mega
	- Source Code created on: 2023-12-24 07:20:59

********* Pleasedontcode.com **********/

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* Reads 14pcs of digital inputs, and sends the */
	/* status of the input as CAN-bus message.  10 */
	/* digital outputs that can be configured easily with */
	/* variables for on-off depending on configured */
	/* digital input status. */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include 
#include 

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);

/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t DI1_PushButton_PIN_D2 = 2;

/***** DEFINITION OF DIGITAL OUTPUT PINS *****/
const uint8_t DO1_Led_PIN_D3 = 3;
const uint8_t DO2_Led_PIN_D4 = 4;

/****** DEFINITION OF LIBRARY CLASS INSTANCES *****/
EasyButton button1(DI1_PushButton_PIN_D2, 35, true, true);

void onButton1Pressed()
{
    // Button1 Pressed callback function
}

void setup(void)
{
    // put your setup code here, to run once:

    // Initialize the button1 object
    // Enable pull-up resistor for the push button
    button1.begin();

    // Attach the onButton1Pressed function as the callback for button1 pressed event
    button1.onPressed(onButton1Pressed);

    // Set the defined digital output pins as output mode
    pinMode(DO1_Led_PIN_D3, OUTPUT);
    pinMode(DO2_Led_PIN_D4, OUTPUT);
}

void loop(void)
{
    // put your main code here, to run repeatedly:

    // Read the state of the button1
    button1.read();

    // Check the state of button1 and set the corresponding digital output pins accordingly
    if (button1.isPressed())
    {
        // Set DO1_Led_PIN_D3 HIGH when button1 is pressed
        digitalWrite(DO1_Led_PIN_D3, HIGH);
    }
    else
    {
        // Set DO1_Led_PIN_D3 LOW when button1 is released
        digitalWrite(DO1_Led_PIN_D3, LOW);
    }

    // ... (Configure the other digital output pins based on other digital input status)
}