pleasedontcode

LED Control rev_01

Nov 15th, 2025
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: LED Control
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-11-15 09:55:43
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Develop a program to read input from the Arduino */
  21.     /* Uno's digital pin 2, and turn on an LED connected */
  22.     /* to digital pin 13 when the button is pressed. */
  23. /****** END SYSTEM REQUIREMENTS *****/
  24.  
  25.  
  26. /* START CODE */
  27.  
  28. // Arduino UNO Input Button and LED Control
  29.  
  30. // Define pin numbers
  31. const int buttonPin = 2;    // Digital pin connected to the push button
  32. const int ledPin = 13;      // Digital pin connected to the LED
  33.  
  34. // Variable to store the button state
  35. int buttonState = 0;
  36.  
  37. void setup() {
  38.   // Initialize serial communication:
  39.   Serial.begin(9600);
  40.   // Set the button pin as input:
  41.   pinMode(buttonPin, INPUT);
  42.   // Set the LED pin as output:
  43.   pinMode(ledPin, OUTPUT);
  44. }
  45.  
  46. void loop() {
  47.   // Read the state of the pushbutton:
  48.   buttonState = digitalRead(buttonPin);
  49.  
  50.   // Check if the pushbutton is pressed.
  51.   // If it is, the buttonState is HIGH:
  52.   if (buttonState == HIGH) {
  53.     // Turn the LED on:
  54.     digitalWrite(ledPin, HIGH);
  55.   } else {
  56.     // Turn the LED off:
  57.     digitalWrite(ledPin, LOW);
  58.   }
  59. }
  60.  
  61. /* END CODE */
  62.  
Advertisement
Add Comment
Please, Sign In to add comment