Good day,
Is there someone that can help with code on the flow chart attached.
It is a simple project for replacing a ice machine controller board which damaged with power surge.
Ice Machine Flow Chart.pdf (20.1 KB)
Good day,
Is there someone that can help with code on the flow chart attached.
It is a simple project for replacing a ice machine controller board which damaged with power surge.
Ice Machine Flow Chart.pdf (20.1 KB)
In Short want to use Uno Arduino to do this.
Pin assignments:
d2 - water sense - Input
d3 - compressor relay - Output
d4 - Water Relay - Output
d5 - Solenoid Relay - Output
d6 - Fan Relay - Output
d7 - Pump Relay - Output
Relay’s switch on LOW,
State off all relays on startup - OFF (High)
What I did so far, but not working as it should.
// and the current state of the SOL
int ws = 2;
int wr= 4;
int readVal; //test phase
float V2; //test phase
int wrState = LOW; // Water Level State
int wsState = LOW;
unsigned long previousMillis0 = 0; // will store last time water inled
long OnTimewr = 3000; // milliseconds of on-time
long OffTimewr = 1000; // milliseconds of off-time
unsigned long MasterMillis = 0; // will store last time SOL was updated
int solPin = 5; // the number of the SOL pin
int solState = HIGH; // solState used to set the SOL
unsigned long SolPreviousMillis = 0; // will store last time SOL was updated
long SolOnTime = 120000; // milliseconds of on-time
long SolOffTime = 1740000; // milliseconds of off-time
// Fan Variables follow
int fanPin = 6; // the number of the FAN pin
int fanState = HIGH; // fanState used to set the FAN
unsigned long FanPreviousMillis = 0; // will store last time FAN was updated
long FanOnTime = 1500000; // milliseconds of on-time
long FanOffTime = 240000; // milliseconds of off-time
// These variables store the flash pattern
// and the current state of the PUMP
int pumpPin = 7; // the number of the PUMP pin
int pumpState = HIGH; // pumpState used to set the PUMP
unsigned long PumpPreviousMillis = 0; // will store last time PUMP was updated
long PumpOnTime = 1560000; // milliseconds of on-time
long PumpOffTime = 180000; // milliseconds of off-time
void setup()
{
Serial.begin (9600);
pinMode(ws, INPUT);
pinMode(wr, OUTPUT);
// set the digital pin as output:
pinMode(solPin, OUTPUT);
// set the digital pin as output:
pinMode(fanPin, OUTPUT);
// set the digital pin as output:
pinMode(pumpPin, OUTPUT);
}
void loop()
{
readVal=digitalRead(ws);
V2=(5./1023.)*readVal;
Serial.print("Level is ");
Serial.print(readVal);
if(readVal==1) //digitalRead(ws == HIGH)) //(wsState == HIGH) && (wrState == HIGH)) //&& (currentMillis - previousMillis0 >= SolOn))
{
wrState = LOW; // Turn it off
// previousMillis1 = currentMillis; // Remember the time
digitalWrite(wr, wrState); // Update the actual LED
}
else if (readVal==0) //digitalRead(ws == LOW)) //(wrState == LOW) && (wrState == LOW)) //&& (currentMillis - previousMillis0 >= SolOff))
{
wrState = HIGH; // turn it on
// previousMillis1 = currentMillis; // Remember the time
digitalWrite(wr, wrState); // Update the actual LED
}
//readVal=digitalRead(watersense);
//V2=(5./1023.)*readVal;
//Serial.print("Level is ");
//Serial.println(readVal);
//if (readVal==1){
// digitalWrite(waterrelay,HIGH);
//}
//if (readVal==0){
// digitalWrite(waterrelay,LOW);
// check to see if it’s time to change the state of the SOL
unsigned long SolMillis = millis();
if((solState == HIGH) && (SolMillis - SolPreviousMillis >= SolOnTime))
{
solState = LOW; // Turn it off
SolPreviousMillis = SolMillis; // Remember the time
digitalWrite(solPin, solState); // Update the actual SOL
}
else if ((solState == LOW) && (SolMillis - SolPreviousMillis >= SolOffTime))
{
solState = HIGH; // turn it on
SolPreviousMillis = SolMillis; // Remember the time
digitalWrite(solPin, solState); // Update the actual SOL
}
// check to see if it’s time to change the state of the FAN
unsigned long FanMillis = millis();
if((fanState == HIGH) && (FanMillis - FanPreviousMillis >= FanOnTime))
{
fanState = LOW; // Turn it off
FanPreviousMillis = FanMillis; // Remember the time
digitalWrite(fanPin, fanState); // Update the actual FAN
}
else if ((fanState == LOW) && (FanMillis - FanPreviousMillis >= FanOffTime))
{
fanState = HIGH; // turn it on
FanPreviousMillis = FanMillis; // Remember the time
digitalWrite(fanPin, fanState); // Update the actual FAN
}
// check to see if it’s time to change the state of the PUMP
unsigned long PumpMillis = millis();
if((pumpState == HIGH) && (PumpMillis - PumpPreviousMillis >= PumpOnTime))
{
pumpState = LOW; // Turn it off
PumpPreviousMillis = PumpMillis; // Remember the time
digitalWrite(pumpPin, pumpState); // Update the actual PUMP
}
else if ((pumpState == LOW) && (PumpMillis - PumpPreviousMillis >= PumpOffTime))
{
pumpState = HIGH; // turn it on
PumpPreviousMillis = PumpMillis; // Remember the time
digitalWrite(pumpPin, pumpState); // Update the actual PUMP
}
}