Advertisement
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: wastesegregation
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2023-11-19 21:32:56
- - Source Code generated by: Rohith
- ********* Pleasedontcode.com **********/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- #include <EasyButton.h>
- /****** SYSTEM REQUIREMENT 1 *****/
- // Opens when object is detected
- // Closes when object is removed
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t openingfordoor_PushButton_PIN_D2 = 2;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- EasyButton openingButton(openingfordoor_PushButton_PIN_D2);
- void setup(void)
- {
- // put your setup code here, to run once:
- Serial.begin(9600); // Initialize Serial for debug purposes
- openingButton.begin();
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- openingButton.read();
- if (openingButton.isPressed())
- {
- // Code to open the door
- Serial.println("Door opened");
- delay(1000); // Delay to avoid rapid button presses
- }
- else if (openingButton.isReleased())
- {
- // Code to close the door
- Serial.println("Door closed");
- delay(1000); // Delay to avoid rapid button releases
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement