Advertisement
pleasedontcode

"LCD Temperature Control" rev_01

Mar 27th, 2024
58
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: "LCD Temperature Control"
  13.     - Source Code compiled for: Arduino Nano
  14.     - Source Code created on: 2024-03-27 18:35:56
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* segna la temperatura dell acqua e attiva una pompa */
  21.     /* quando raggiunge i 40 gradi */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <Wire.h>
  26. #include <LiquidCrystal_I2C.h>
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31. int readTemperature();
  32. void activatePump();
  33.  
  34. /***** DEFINITION OF I2C PINS *****/
  35. const uint8_t Temp_LCD1602I2C_I2C_PIN_SDA_A4 = A4;
  36. const uint8_t Temp_LCD1602I2C_I2C_PIN_SCL_A5 = A5;
  37. const uint8_t Temp_LCD1602I2C_I2C_SLAVE_ADDRESS = 0x27;
  38.  
  39. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  40. LiquidCrystal_I2C lcd(Temp_LCD1602I2C_I2C_SLAVE_ADDRESS, 16, 2);
  41.  
  42. void setup(void)
  43. {
  44.   // Initialize the LCD display
  45.   lcd.begin(16, 2);
  46.   lcd.backlight();
  47.  
  48.   // Put your setup code here, to run once:
  49. }
  50.  
  51. void loop(void)
  52. {
  53.   // Put your main code here, to run repeatedly:
  54.  
  55.   // Check if the water temperature reaches 40 degrees
  56.   int temperature = readTemperature();
  57.   if (temperature >= 40) {
  58.     activatePump();
  59.     lcd.clear();
  60.     lcd.setCursor(0, 0);
  61.     lcd.print("Water temperature:");
  62.     lcd.setCursor(0, 1);
  63.     lcd.print(temperature);
  64.   }
  65.  
  66.   // Delay for some time before checking again
  67.   delay(1000);
  68. }
  69.  
  70. int readTemperature() {
  71.   // Code to read and return the water temperature
  72.   // Replace with your actual implementation
  73.   // For example, you can use a temperature sensor and the appropriate library functions
  74. }
  75.  
  76. void activatePump() {
  77.   // Code to activate the pump
  78.   // Replace with your actual implementation
  79.   // For example, you can control a relay or a motor driver to turn on the pump
  80. }
  81.  
  82. /****************** END OF CODE ******************/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement