CCCPaste

LED 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: LED Control
	- Source Code NOT compiled for: Arduino Uno
	- Source Code created on: 2025-11-15 09:55:43

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

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* Develop a program to read input from the Arduino */
	/* Uno's digital pin 2, and turn on an LED connected */
	/* to digital pin 13 when the button is pressed. */
/****** END SYSTEM REQUIREMENTS *****/


/* START CODE */

// Arduino UNO Input Button and LED Control

// Define pin numbers
const int buttonPin = 2;    // Digital pin connected to the push button
const int ledPin = 13;      // Digital pin connected to the LED

// Variable to store the button state
int buttonState = 0;

void setup() {
  // Initialize serial communication:
  Serial.begin(9600);
  // Set the button pin as input:
  pinMode(buttonPin, INPUT);
  // Set the LED pin as output:
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // Read the state of the pushbutton:
  buttonState = digitalRead(buttonPin);

  // Check if the pushbutton is pressed.
  // If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // Turn the LED on:
    digitalWrite(ledPin, HIGH);
  } else {
    // Turn the LED off:
    digitalWrite(ledPin, LOW);
  }
}

/* END CODE */