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: Temperature Monitor
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2023-12-06 21:14:09
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Turns on the built-in LED when the temperature */
- /* exceeds 75 degrees Fahrenheit. */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- #include <DS18B20.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t accurateTemperature_DS18B20_DQ_PIN_D2 = 2;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- DS18B20 ds(accurateTemperature_DS18B20_DQ_PIN_D2);
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(LED_BUILTIN, OUTPUT);
- // Turns on the built-in LED when the temperature exceeds 75 degrees Fahrenheit
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- // Read temperature from DS18B20 sensor
- float temperature = ds.getTempC();
- // Display temperature on Serial Monitor
- Serial.print("Temperature: ");
- Serial.print(temperature);
- Serial.println(" °C");
- // Check if temperature exceeds 75 degrees Fahrenheit
- if (temperature > 75) {
- digitalWrite(LED_BUILTIN, HIGH); // Turn on built-in LED
- } else {
- digitalWrite(LED_BUILTIN, LOW); // Turn off built-in LED
- }
- delay(1000); // Wait for 1 second
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement