CCCPaste

Debounced Button 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: Debounced Button
	- Source Code NOT compiled for: ESP32 DevKit V1
	- Source Code created on: 2025-10-25 16:39:57

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

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* Define a user requirement for continuously */
	/* monitoring a push button on GPIO0 to turn an */
	/* onboard LED on GPIO2 on press and off on release, */
	/* utilizing GPIO functionalities of the connected */
	/* components. */
/****** END SYSTEM REQUIREMENTS *****/


/* START CODE */

/****** DEFINITION OF LIBRARIES *****/

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

// GPIO definitions
const int BUTTON_PIN = 0;
const int LED_PIN = 2;


void setup(void)
{
	// put your setup code here, to run once:
	pinMode(BUTTON_PIN, INPUT_PULLUP);
	pinMode(LED_PIN, OUTPUT);
	// Ensure the LED is OFF initially
	digitalWrite(LED_PIN, LOW);
}


void loop(void)
{
	// put your main code here, to run repeatedly:
	int buttonState = digitalRead(BUTTON_PIN);
	if (buttonState == LOW)
	{
		// Button pressed: turn LED ON
		digitalWrite(LED_PIN, HIGH);
	}
	else
	{
		// Button released: turn LED OFF
		digitalWrite(LED_PIN, LOW);
	}
	// Small delay for basic debouncing
	delay(10);
}

/* END CODE */