Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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 Controller
- - Source Code NOT compiled for: Arduino Mega
- - Source Code created on: 2025-11-15 18:03:49
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* if b13 = low and b12 = low , l11 = HIGH if b13 = */
- /* low and b12 = HIGH , l11 = HIGH if b13 = HIGH and */
- /* b12 = low , l11 = HIGH if b13 = HIGH and b12 = */
- /* HIGH , l11 =low */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- // System Requirements:
- // This program reads the states of two push buttons connected to pins 13 and 12.
- // Controls an LED connected to pin 11 based on the button presses.
- // The LED turns ON or OFF depending on the combination of button states.
- void setup() {
- // Initialize push buttons as input with internal pull-up resistors
- pinMode(13, INPUT_PULLUP); // Push Button 1
- pinMode(12, INPUT_PULLUP); // Push Button 2
- // Initialize LED pin as output
- pinMode(11, OUTPUT); // LED
- }
- void loop() {
- // Read the state of the push buttons
- bool button1 = digitalRead(13); // Button 1 state
- bool button2 = digitalRead(12); // Button 2 state
- // Determine LED state based on button states
- // According to system requirements:
- // "if b13 = low and b12 = low, l11 = HIGH"
- // "if b13 = low and b12 = HIGH, l11 = HIGH"
- // "if b13 = HIGH and b12 = low, l11 = HIGH"
- // "if b13 = HIGH and b12 = HIGH, l11 = LOW"
- if ((button1 == LOW && button2 == LOW) ||
- (button1 == LOW && button2 == HIGH) ||
- (button1 == HIGH && button2 == LOW)) {
- digitalWrite(11, HIGH); // Turn ON LED
- } else {
- digitalWrite(11, LOW); // Turn OFF LED
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment