Advertisement
pleasedontcode

homeAutomation rev_52

Nov 27th, 2023
101
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: homeAutomation
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-11-28 01:26:35
  15.     - Source Code generated by: Francesco Alessandro
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <DS18B20.h>
  21.  
  22. /****** FUNCTION PROTOTYPES *****/
  23. void setup(void);
  24. void loop(void);
  25.  
  26. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  27. const uint8_t temperatureSensor_DS18B20_DQ_PIN_D2 = 2;
  28. const uint8_t buzzerPin = 3; // Define the buzzer pin
  29.  
  30. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  31. DS18B20 ds(temperatureSensor_DS18B20_DQ_PIN_D2);
  32.  
  33. void setup(void)
  34. {
  35.   // put your setup code here, to run once:
  36.   pinMode(buzzerPin, OUTPUT); // Set the buzzer pin as output
  37. }
  38.  
  39. void loop(void)
  40. {
  41.   // put your main code here, to run repeatedly:
  42.   float temperature = ds.getTempC(); // Use getTempC() instead of getTemperature()
  43.  
  44.   if (temperature > 10) {
  45.     // Sound the buzzer
  46.     // TODO: Write code to sound the buzzer
  47.     digitalWrite(buzzerPin, HIGH);
  48.   } else {
  49.     digitalWrite(buzzerPin, LOW);
  50.   }
  51.  
  52.   delay(1000);
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement