Question: Create an Arduino program that manages a washing machine where... a . There is a Fill Controlled by an RC circuit. b . There is

Create an Arduino program that manages a washing machine where...
a. There is a Fill Controlled by an RC circuit.
b. There is a Wash Controlled by an RC circuit.
c. There is a Spin/rinse Controlled by an RC circuit.
d. Then are Empty timers between Wash and Spin/rinse - Controlled by an RC
circuit.
There should be a START that starts the process.
There should not be a pause if the door lid is open.
There should be an indicator light for each step in the wash cycle.
When the final spin is done a DONE_BUZZER should sound, and a light should flash.
Use an Arduino timer using a timer interrupt to
There needs to be a RESET, which can reset the wash cycle.
When the Fill cycle is active, or the Rinse is active then a FILL_VALVE is energized to
allow water into the washing machine. The FILL_VALVE should only allow water to flow
for 5 seconds.
You need to use an i2C LCD display to state in English what state the washing machine
is in.
The DONE_BUZZER cannot activate while the EMPTY_VALVE is energized.
The LCD will not print fill,wash, rinse,or done using this program. that was sent to me.
// C++ code
//
#include
int seconds =0;
float fillValve =0.0;
Adafruit_LiquidCrystal lcd_1(0);
// Pin assignments
const int START_BUTTON =2;
const int RESET_BUTTON =3;
const int FILL_VALVE =4;
const int EMPTY_VALVE =5;
const int DONE_BUZZER =6;
const int FILL_LIGHT =7;
const int WASH_LIGHT =8;
const int SPIN_LIGHT =9;
const int DONE_LIGHT =10;
// State variables
enum MachineState {
IDLE,
FILLING,
WASHING,
RINSING,
SPINNING,
DONE
};
MachineState state = IDLE;
// Timers and durations
unsigned long fillStartTime;
unsigned long washStartTime;
unsigned long rinseStartTime;
unsigned long spinStartTime;
const unsigned long fillDuration =5000; //5 seconds for fill
const unsigned long washDuration =5000; //5 seconds for wash
const unsigned long rinseDuration =5000; //5 seconds for rinse
const unsigned long spinDuration =5000; //5 seconds for spin
// Initialization function
void setup(){
// Pin initialization
pinMode(START_BUTTON, INPUT_PULLUP);
pinMode(RESET_BUTTON, INPUT_PULLUP);
pinMode(FILL_VALVE, OUTPUT);
pinMode(EMPTY_VALVE, OUTPUT);
pinMode(DONE_BUZZER, OUTPUT);
pinMode(FILL_LIGHT, OUTPUT);
pinMode(WASH_LIGHT, OUTPUT);
pinMode(SPIN_LIGHT, OUTPUT);
pinMode(DONE_LIGHT, OUTPUT);
// Initialize I2C LCD display
lcd_1.begin(16,2);
lcd_1.setBacklight(1);
lcd_1.clear();
// Initial state of outputs
digitalWrite(FILL_VALVE, LOW);
digitalWrite(EMPTY_VALVE, LOW);
digitalWrite(DONE_BUZZER, LOW);
}
// Loop function
void loop(){
// Handle start button press
if (digitalRead(START_BUTTON)== LOW){
// Start the washing cycle if not already started
if (state == IDLE){
state = FILLING;
fillStartTime = millis();
digitalWrite(FILL_VALVE, HIGH); // Energize fill valve
digitalWrite(FILL_LIGHT, HIGH); // Turn on fill light
lcd_1.clear();
lcd_1.print("Filling");
}
}
// Handle reset button press
if (digitalRead(RESET_BUTTON)== LOW){
// Reset the washing cycle
state = IDLE;
digitalWrite(FILL_VALVE, LOW);
digitalWrite(EMPTY_VALVE, LOW);
digitalWrite(DONE_BUZZER, LOW);
digitalWrite(FILL_LIGHT, LOW);
digitalWrite(WASH_LIGHT, LOW);
digitalWrite(SPIN_LIGHT, LOW);
digitalWrite(DONE_LIGHT, LOW);
lcd_1.clear();
lcd_1.print("Idle");
}
// State machine for washing cycle
switch (state){
case FILLING:
// Check fill duration
if (millis()- fillStartTime >= fillDuration){
// Move to washing state
state = WASHING;
digitalWrite(FILL_VALVE, LOW); // Turn off fill valve
digitalWrite(FILL_LIGHT, LOW); // Turn off fill light
washStartTime = millis();
digitalWrite(WASH_LIGHT, HIGH); // Turn on wash light
lcd_1.clear();
lcd_1.print("Washing");
}
break;
case WASHING:
// Check wash duration
if (millis()- washStartTime >= washDuration){
// Move to rinsing state
state = RINSING;
washStartTime = millis();
digitalWrite(WASH_LIGHT, LOW); // Turn off wash light
digitalWrite(EMPTY_VALVE, HIGH); // Energize empty valve
lcd_1.clear();
lcd_1.print("Rinsing");
}
break;
case RINSING:
// Check rinse duration
if (millis()- rinseStartTime >= rinseDuration){
// Move to spinning state

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!