Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write code to produce a program to the below specification: Code must alternate pumps on start up FIGURE 1 shows part of a control system
Write code to produce a program to the below specification:
Code must alternate pumps on start up
FIGURE shows part of a control system used to maintain the water level in a
sump between the levels high and low. Two transducers HIGH and LOW are
used to monitor the level. The water is pumped out by two pumps, P and P
The water level in the sump is to be controlled as follows:
If the level reaches high one pump will start to pump out.
If the level does not reach low within about seconds, the second pump
will come into action. If the level does reach low before second
pumping should stop.
If the level does not reach low within about seconds of the second
pump starting, an alarm is given. The alarm is sounded until the level
reaches low. If the level does reach low before seconds the pumping
should stop.
The pumps will stop when low is detected.
To give even loading of the pumps they are to be used alternately, eg if
on one pump cycle P starts first and P is the back up then on the next
cycle P will start first and P is the back up
Please check your program functions as per the specification and i will leave you thumbs up
Please check this code to see where I am going wrong. Must simulate the code using tinkercad before answering question:
const int HIGHTRANSPIN ; Replace with the actual pin number for the HIGH transducer
const int LOWTRANSPIN ; Replace with the actual pin number for the LOW transducer
const int PUMPLEDPIN ; Replace with the actual pin number for the first pump LED
const int PUMPLEDPIN ; Replace with the actual pin number for the second pump LED
const int ALARMLEDPIN ; Replace with the actual pin number for the alarm LED
unsigned long previousMillis ;
const long interval ; seconds interval
void setup
pinModeHIGHTRANSPIN, INPUT;
pinModeLOWTRANSPIN, INPUT;
pinModePUMPLEDPIN, OUTPUT;
pinModePUMPLEDPIN, OUTPUT;
pinModeALARMLEDPIN, OUTPUT;
void loop
unsigned long currentMillis millis;
bool pumpActive true; Start with pump
inside the loop
if digitalReadHIGHTRANSPIN HIGH
if pumpActive
digitalWritePUMPLEDPIN, HIGH;
pump actions
else
digitalWritePUMPLEDPIN, HIGH;
pump actions
pumpActive pumpActive; Toggle active pump
Check water level and take appropriate action
if digitalReadHIGHTRANSPIN HIGH
High level reached, start pumping
digitalWritePUMPLEDPIN, HIGH;
delay; Pumping time adjust as needed
digitalWritePUMPLEDPIN, LOW;
Check if low level is reached within seconds
if digitalReadLOWTRANSPIN LOW
Low level reached, stop pumping
digitalWritePUMPLEDPIN, LOW;
digitalWriteALARMLEDPIN, LOW;
else
Low level not reached within seconds, activate second pump
digitalWritePUMPLEDPIN, HIGH;
delay; Pumping time adjust as needed
digitalWritePUMPLEDPIN, LOW;
Check if low level is reached within seconds
if digitalReadLOWTRANSPIN LOW
Low level reached, stop pumping
digitalWriteALARMLEDPIN, LOW;
else
Low level not reached within additional seconds, sound alarm
digitalWriteALARMLEDPIN, HIGH;
Reset the timer
previousMillis currentMillis;
Check if seconds have passed since the last check
if currentMillis previousMillis interval
seconds passed, stop all pumps and alarm
digitalWritePUMPLEDPIN, LOW;
digitalWritePUMPLEDPIN, LOW;
digitalWriteALARMLEDPIN, LOW;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started