Advertisement
pleasedontcode

POV_CLOCK rev_01

Nov 10th, 2023
83
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: POV_CLOCK
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-11-11 05:48:09
  15.     - Source Code generated by: SSS Shivansh
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <EasyButton.h>
  21.  
  22. /****** SYSTEM REQUIREMENT 1 *****/
  23. /* I want whenever the PIR motion detector detects a */
  24. /* motion the led turns on */
  25.  
  26. /****** FUNCTION PROTOTYPES *****/
  27. void setup(void);
  28. void loop(void);
  29.  
  30. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  31. const uint8_t PIR_MOTION_DETECTOR_PIN = 2;
  32. const uint8_t LED_PIN = 13;
  33.  
  34. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  35. EasyButton button(PIR_MOTION_DETECTOR_PIN);
  36.  
  37. void setup(void)
  38. {
  39.   // Set the LED pin as output
  40.   pinMode(LED_PIN, OUTPUT);
  41.  
  42.   // Initialize the button.
  43.   button.begin();
  44. }
  45.  
  46. void loop(void)
  47. {
  48.   // Read the button state
  49.   button.read();
  50.  
  51.   // Check if the button is pressed
  52.   if (button.isPressed()) {
  53.     // Turn on the LED
  54.     digitalWrite(LED_PIN, HIGH);
  55.   } else {
  56.     // Turn off the LED
  57.     digitalWrite(LED_PIN, LOW);
  58.   }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement