CCCPaste

Button Motor 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 Motor
	- Source Code compiled for: Arduino Uno
	- Source Code created on: 2024-03-06 10:44:47

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

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* Rotate right and left depends on the button click */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include     //https://github.com/evert-arias/EasyButton
#include     //https://github.com/AndreaLombardo/L298N

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

/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t button_PushButton_PIN_D2 = 2;
const uint8_t button_PushButton_PIN_D3 = 3;

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
EasyButton button_PushButton_D2(button_PushButton_PIN_D2);
EasyButton button_PushButton_D3(button_PushButton_PIN_D3);
L298NX2 motor(9, 8, 7, 6); // Update the pin configurations according to your setup

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

    pinMode(button_PushButton_PIN_D2, INPUT_PULLUP);
    pinMode(button_PushButton_PIN_D3, INPUT_PULLUP);

    button_PushButton_D2.begin();
    button_PushButton_D3.begin();

    // Register callback functions for button presses
    button_PushButton_D2.onPressed(rotateRight);
    button_PushButton_D3.onPressed(rotateLeft);
}

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

    button_PushButton_D2.read();
    button_PushButton_D3.read();

    // Add your code logic based on the button state here
}

void rotateRight()
{
    // Add code to rotate right here
}

void rotateLeft()
{
    // Add code to rotate left here
}