Advertisement
pleasedontcode

Washing Controller rev_01

Oct 21st, 2024
107
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: Washing Controller
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-10-22 02:31:08
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* 1- When you press the start button, it says on the */
  21.     /* screen that the wash has started    2- Wait 1 */
  22.     /* second and close the door    3- Wait 1 second and */
  23.     /* open the water valve and write that on the screen */
  24.     /* Then t */
  25. /****** END SYSTEM REQUIREMENTS *****/
  26.  
  27. /****** DEFINITION OF LIBRARIES *****/
  28. #include <Wire.h>
  29. #include <LiquidCrystal_I2C.h>  //https://github.com/marcoschwartz/LiquidCrystal_I2C
  30.  
  31. /****** FUNCTION PROTOTYPES *****/
  32. void setup(void);
  33. void loop(void);
  34.  
  35. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  36. const uint8_t START_BUTTON_PIN_A0       = A0;
  37. const uint8_t STOP_BUTTON_PIN_A1        = A1;
  38. const uint8_t WATER_LEVEL_PIN_A2        = A2;
  39.  
  40. /***** DEFINITION OF I2C PINS *****/
  41. const uint8_t Lcd_LCD1602I2C_I2C_PIN_SDA_A4     = A4;
  42. const uint8_t Lcd_LCD1602I2C_I2C_PIN_SCL_A5     = A5;
  43. const uint8_t Lcd_LCD1602I2C_I2C_SLAVE_ADDRESS      = 39;
  44.  
  45. /****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/
  46. // Initialize the LiquidCrystal_I2C object with the I2C address and dimensions
  47. LiquidCrystal_I2C lcd(Lcd_LCD1602I2C_I2C_SLAVE_ADDRESS, 20, 4); // 20 columns and 4 rows
  48.  
  49. void setup(void)
  50. {
  51.     // Initialize the LCD
  52.     lcd.init(); // Initialize the LCD
  53.     lcd.backlight(); // Turn on the backlight
  54.  
  55.     // Set up pin modes for buttons and water level sensor
  56.     pinMode(START_BUTTON_PIN_A0, INPUT_PULLUP);
  57.     pinMode(STOP_BUTTON_PIN_A1, INPUT_PULLUP);
  58.     pinMode(WATER_LEVEL_PIN_A2, INPUT);
  59.    
  60.     // Display initial messages on the LCD
  61.     lcd.setCursor(3, 0);
  62.     lcd.print("Hello, world!");
  63.     lcd.setCursor(2, 1);
  64.     lcd.print("Ywrobot Arduino!");
  65.     lcd.setCursor(0, 2);
  66.     lcd.print("Arduino LCM IIC 2004");
  67.     lcd.setCursor(2, 3);
  68.     lcd.print("Power By Ec-yuan!");
  69. }
  70.  
  71. void loop(void)
  72. {
  73.     // Check if the start button is pressed
  74.     if (digitalRead(START_BUTTON_PIN_A0) == LOW) // Button pressed
  75.     {
  76.         // Indicate that the wash has started
  77.         lcd.clear(); // Clear the LCD
  78.         lcd.setCursor(0, 0);
  79.         lcd.print("Wash Started!"); // Display wash started message
  80.         delay(1000); // Wait for 1 second
  81.  
  82.         // Close the door (simulated)
  83.         lcd.setCursor(0, 1);
  84.         lcd.print("Closing Door..."); // Display closing door message
  85.         delay(1000); // Wait for 1 second
  86.  
  87.         // Open the water valve
  88.         lcd.setCursor(0, 2);
  89.         lcd.print("Opening Valve..."); // Display opening valve message
  90.         delay(1000); // Wait for 1 second
  91.  
  92.         // Indicate that the water valve is open
  93.         lcd.setCursor(0, 3);
  94.         lcd.print("Water Valve Open"); // Display water valve open message
  95.     }
  96. }
  97.  
  98. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement