Advertisement
pleasedontcode

Remote rev_02

Oct 25th, 2023
57
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: Remote
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-10-25 15:02:03
  15.     - Source Code generated by: hetal
  16.  
  17. ********* Pleasedontcode.com **********/
  18.  
  19. /********* User code review feedback **********
  20. #### Feedback 1 ####
  21. - I want more according to my requirements
  22.  
  23. ********* User code review feedback **********/
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <Arduino.h>
  27. #include <EasyButton.h>
  28.  
  29. /****** SYSTEM REQUIREMENT 1 *****/
  30. const uint8_t Relay_PIN = 3; // Pin for controlling the relay
  31. const uint8_t PushButton_PIN = 2; // Pin for the push button
  32.  
  33. EasyButton pushButton(PushButton_PIN); // Create an instance of the EasyButton library
  34.  
  35. void setup(void)
  36. {
  37.   pinMode(Relay_PIN, OUTPUT); // Set the relay pin as output
  38.   pushButton.begin(); // Initialize the push button
  39.  
  40.   // Attach a function to be called when the button is pressed
  41.   pushButton.onPressed([]() {
  42.     digitalWrite(Relay_PIN, !digitalRead(Relay_PIN)); // Toggle the relay state
  43.   });
  44. }
  45.  
  46. void loop(void)
  47. {
  48.   pushButton.read(); // Read the state of the push button
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement