pleasedontcode

LED Controller rev_01

Nov 15th, 2025
324
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 Controller
  13.     - Source Code NOT compiled for: Arduino Mega
  14.     - Source Code created on: 2025-11-15 18:03:49
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* if b13 = low and b12 = low , l11 = HIGH  if b13 = */
  21.     /* low and b12 = HIGH , l11 = HIGH  if b13 = HIGH and */
  22.     /* b12 = low , l11 = HIGH  if b13 = HIGH and b12 = */
  23.     /* HIGH , l11 =low */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26.  
  27. /* START CODE */
  28.  
  29. // System Requirements:
  30. // This program reads the states of two push buttons connected to pins 13 and 12.
  31. // Controls an LED connected to pin 11 based on the button presses.
  32. // The LED turns ON or OFF depending on the combination of button states.
  33.  
  34. void setup() {
  35.   // Initialize push buttons as input with internal pull-up resistors
  36.   pinMode(13, INPUT_PULLUP); // Push Button 1
  37.   pinMode(12, INPUT_PULLUP); // Push Button 2
  38.   // Initialize LED pin as output
  39.   pinMode(11, OUTPUT); // LED
  40. }
  41.  
  42. void loop() {
  43.   // Read the state of the push buttons
  44.   bool button1 = digitalRead(13); // Button 1 state
  45.   bool button2 = digitalRead(12); // Button 2 state
  46.  
  47.   // Determine LED state based on button states
  48.   // According to system requirements:
  49.   // "if b13 = low and b12 = low, l11 = HIGH"
  50.   // "if b13 = low and b12 = HIGH, l11 = HIGH"
  51.   // "if b13 = HIGH and b12 = low, l11 = HIGH"
  52.   // "if b13 = HIGH and b12 = HIGH, l11 = LOW"
  53.  
  54.   if ((button1 == LOW && button2 == LOW) ||
  55.       (button1 == LOW && button2 == HIGH) ||
  56.       (button1 == HIGH && button2 == LOW)) {
  57.     digitalWrite(11, HIGH); // Turn ON LED
  58.   } else {
  59.     digitalWrite(11, LOW); // Turn OFF LED
  60.   }
  61. }
  62.  
  63. /* END CODE */
  64.  
Advertisement
Add Comment
Please, Sign In to add comment