guys, im having a bit of trouble sorting this out. i have a set of buttons some manual some that call eeprom value and set outputs to HIGH and quit them as soon as pressure is reached. now, im trying to add function, so if within 10second pressure is NOT reached, it will change state to LOW.
Now, i have 4 outputs:
output #1
if (FLSolUp == HIGH);
if (millis() - onTime > elapsedTime) {
if(pressureFL < EEPROM.read(20))
{
doNothingFL();
}
}
the other 3 are the same just different pins.
Problem is that those pins run low after 10seconds from reset instead from reading "HIGH" making my manual control unusable.
I cannot post the whole code as exeed max allowed 9000 char
ok. that does work, but also makes my manual inputs unusable. I don`t know how to call this timer only with double click so manual control is not affected.
My loop
void loop()
{
//Single
//All UP
if (digitalRead(allUp) == LOW)
{
digitalWrite (FLSolUp, HIGH);
digitalWrite (FRSolUp, HIGH);
digitalWrite (RLSolUp, HIGH);
digitalWrite (RRSolUp, HIGH);
}
//All down
if (digitalRead(allDown) == LOW)
{
digitalWrite (FLSolDown, HIGH);
digitalWrite (FRSolDown, HIGH);
digitalWrite (RLSolDown, HIGH);
digitalWrite (RRSolDown, HIGH);
}
int reading = digitalRead(autoAllUp); //single button you assign for double and hold press
if(pressureFL >= EEPROM.read(20)) //Need 5 eeprom addresses and tag pressure from 1-5 rg. pressure1, pressure2.
{
doNothingFL();
}
if(pressureFR >= EEPROM.read(30))
{
doNothingFR();
}
if(pressureRL >= EEPROM.read(40))
{
doNothingRL();
}
if(pressureRR >= EEPROM.read(50))
{
doNothingRR();
}
if (digitalRead(FLSolUp == HIGH))
if (millis() - onTime > elapsedTime) {
if(pressureFL < EEPROM.read(20))
{
doNothingFL();
}
}
if (digitalRead(FRSolUp == HIGH))
if (millis() - onTime > elapsedTime) {
if(pressureFR < EEPROM.read(30))
{
doNothingFR();
}
}
if (digitalRead(RLSolUp == HIGH))
if (millis() - onTime > elapsedTime) {
if(pressureRL < EEPROM.read(30))
{
doNothingRL();
}
}
if (digitalRead(RRSolUp == HIGH))
if (millis() - onTime > elapsedTime) {
if(pressureRR < EEPROM.read(30))
{
doNothingRR();
}
}
//First Pressed
if(reading == LOW && lastReading == HIGH) {
onTime = millis();
}
//Held
if(reading == LOW && lastReading == LOW) {
if((millis() - onTime) > holdTime) {
hold = 1;
blinkLED();
}
}
//Released
if (reading == HIGH && lastReading == LOW) {
if (((millis() - onTime) > bounceTime) && hold != 1) {
doublePress();
}
if(hold == 1) {
Serial.println("HELD");
storeMemoryFL();
storeMemoryFR();
storeMemoryRL();
storeMemoryRR();
hold = 0;
}
}
lastReading = reading;
if (single == 1 && (millis() - lastSwitchTime) > doubleSwitchTime) {
Serial.println ("SINGLE PRESS");
single = 0;
}
Say you store 100psi in eeprom. If its lower that 100psi your inflate button FLUp is low permamently but FLDown can be used.
If you go over 100Psi your FLDown becomes LOW permanently but FLUp can be used.
If pressure hits 100Psi or any other value that is stored in eeprom that both FLUp and FLDown are permamently LOW disabling any manual operation for example if you want to adjust pressure and store new value.
I understand that.
The reason I want to know what the pressure is, is because before this IF statement, the pressure is a random number (int pressureFL; ).
Ill test your code with dummy values when I get home in about an hour. Ill try to recreate what you are seeing.