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: homeAutomation
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2023-11-15 23:44:57
- - Source Code generated by: Francesco Alessandro
- ********* Pleasedontcode.com **********/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- #include <DS18B20.h>
- /****** SYSTEM REQUIREMENT 1 *****/
- /* If temperature gets above 10°C, the buzzer will sound. */
- /****** FUNCTION PROTOTYPES *****/
- void setup();
- void loop();
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t temperatureSensor_DS18B20_DQ_PIN_D2 = 2;
- const uint8_t buzzerPin = 3;
- /****** DEFINITION OF LIBRARY CLASS INSTANCES *****/
- DS18B20 ds(temperatureSensor_DS18B20_DQ_PIN_D2);
- void setup()
- {
- // Set pin modes
- pinMode(temperatureSensor_DS18B20_DQ_PIN_D2, INPUT);
- pinMode(buzzerPin, OUTPUT);
- }
- void loop()
- {
- // Read temperature from DS18B20 sensor
- float temperature = ds.getTempC();
- // Check if temperature is above 10°C
- if (temperature > 10)
- {
- // Sound the buzzer
- digitalWrite(buzzerPin, HIGH);
- }
- else
- {
- // Turn off the buzzer
- digitalWrite(buzzerPin, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement