Advertisement
pleasedontcode

Irrigation_system rev_01

Nov 22nd, 2023
98
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: Irrigation_system
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-11-23 05:08:17
  15.     - Source Code generated by: Akhilesh
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <Wire.h>
  21. #include <LiquidCrystal_I2C.h>
  22. #include <DS18B20.h>
  23.  
  24. /****** SYSTEM REQUIREMENT 1 *****/
  25. /* Temperature monitoring */
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30.  
  31. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  32. const uint8_t Temp_DS18B20_DQ_PIN_D2 = 2;
  33.  
  34. /***** DEFINITION OF I2C PINS *****/
  35. const uint8_t LCD_LCD1602I2C_I2C_PIN_SDA_A4 = A4;
  36. const uint8_t LCD_LCD1602I2C_I2C_PIN_SCL_A5 = A5;
  37. const uint8_t LCD_LCD1602I2C_I2C_SLAVE_ADDRESS = 0x27;
  38.  
  39. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  40. LiquidCrystal_I2C lcd(LCD_LCD1602I2C_I2C_SLAVE_ADDRESS, 20, 4);
  41. DS18B20 ds(Temp_DS18B20_DQ_PIN_D2); // Initialize DS18B20 object with the DQ pin
  42.  
  43. void setup(void)
  44. {
  45.   // put your setup code here, to run once:
  46.   pinMode(Temp_DS18B20_DQ_PIN_D2, INPUT);
  47.  
  48.   lcd.init();
  49.   lcd.backlight();
  50.  
  51.   // Add your initialization code here:
  52.   Serial.begin(9600); // Initialize the serial communication
  53.  
  54. }
  55.  
  56. void loop(void)
  57. {
  58.   // put your main code here, to run repeatedly:
  59.   float temperature = ds.getTempC(); // Read temperature from DS18B20 sensor
  60.  
  61.   lcd.clear(); // Clear the LCD screen
  62.   lcd.setCursor(0, 0); // Set the cursor to the first position of the first line
  63.   lcd.print("Temperature: "); // Print the text
  64.   lcd.print(temperature); // Print the temperature value
  65.  
  66.   Serial.print("Temperature: "); // Print the text on the serial monitor
  67.   Serial.print(temperature); // Print the temperature value on the serial monitor
  68.  
  69.   delay(1000); // Delay for 1 second
  70.  
  71. }
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement