CCCPaste

Button Control rev_190

/********* 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 Nano ESP32
	- Source Code created on: 2024-01-14 12:50:20

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

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* if button is pressed so activate outdid */
/****** END SYSTEM REQUIREMENTS *****/

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

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

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

/***** DEFINITION OF DIGITAL OUTPUT PINS *****/
const uint8_t outdig_PIN_D3 = 3;

/***** DEFINITION OF PWM OUTPUT PINS *****/
const uint8_t outpwm_PIN_D12 = 12;

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
EasyButton button(button_PushButton_PIN_D2);

void setup(void)
{
  // put your setup code here, to run once:
  pinMode(button_PushButton_PIN_D2, INPUT_PULLUP);
  pinMode(outdig_PIN_D3, OUTPUT);
  pinMode(outpwm_PIN_D12, OUTPUT);
}

void loop(void)
{
  // put your main code here, to run repeatedly:
  button.read(); // Read the button state

  if (button.isPressed()) {
    digitalWrite(outdig_PIN_D3, HIGH); // Activate the digital output pin
    analogWrite(outpwm_PIN_D12, 255); // Set PWM output to maximum value
  } else {
    digitalWrite(outdig_PIN_D3, LOW); // Deactivate the digital output pin
    analogWrite(outpwm_PIN_D12, 0); // Set PWM output to minimum value
  }
}