Advertisement
pleasedontcode

Sensor Control rev_01

Feb 13th, 2024
71
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: Sensor Control
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-02-13 09:51:16
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* The system shall turn off the light emitting diode */
  21.     /* connected to pin D2 when the button connected to */
  22.     /* pin D2 is pressed. */
  23. /****** END SYSTEM REQUIREMENTS *****/
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include "DHT.h"
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31.  
  32. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  33. const uint8_t buttonPin = 2;
  34. const uint8_t ledPin = 3;
  35.  
  36. /****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/
  37. DHT dht(buttonPin, DHT22);
  38.  
  39. void setup(void) {
  40.   // put your setup code here, to run once:
  41.   pinMode(buttonPin, INPUT_PULLUP);
  42.   pinMode(ledPin, OUTPUT);
  43.  
  44.   Serial.begin(9600);
  45. }
  46.  
  47. void loop(void) {
  48.   // put your main code here, to run repeatedly:
  49.   if (digitalRead(buttonPin) == LOW) {
  50.     digitalWrite(ledPin, LOW); // Turn off the LED
  51.   } else {
  52.     digitalWrite(ledPin, HIGH); // Turn on the LED
  53.   }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement