Hi,
I am very new and my programming is in the beginning so i have a short question, hope you can help me out.
I am working on a Motor that is controlled over a relai board, that is allready working...
It shoul be used as Aquarium Filter turn every 24h, so i wrote a code that put operation high for 250ms every 24h 86400000ms
Between Motor and Ralai i have a speed controller with switch between forward and backward.. normal is forward, but to switch filter i need to but it in reverse and than i want to push a botton, during that time the motor should spin.
My problem is during the 24h waiting periot in the [loop] it does not matter if i push my capacitv sensor or not..it will i just have like 1sek a day i could touch the botton ![]()
I need help to fix that.
It should stay in the normal mode 24h wait / 250ms spin when the botton is NOT pushed,.. if i push it it should spin
MY Code:
int relais1pin = 1;
int relais3pin = 3;
int relais4pin = 4;
int sensorpin = 2;
void setup() {
pinMode(relais1pin,OUTPUT);
pinMode(relais3pin,OUTPUT);
pinMode(relais4pin,OUTPUT);
Serial.begin(9600);
pinMode(sensorpin, INPUT);
pinMode (LED_BUILTIN, OUTPUT);
}
void loop() {
int sensorstate = digitalRead(sensorpin);
if (sensorstate == 1) {
Serial.println("Cap. Sensor active");
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(relais1pin,HIGH);
digitalWrite(relais3pin,HIGH);
digitalWrite(relais4pin,HIGH);
} else {
Serial.println("Cap. Sensor not active");
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
// move
digitalWrite(relais1pin,HIGH);
digitalWrite(relais3pin,HIGH);
digitalWrite(relais4pin,HIGH);
delay(15000);
// not move
digitalWrite(relais1pin,LOW);
digitalWrite(relais3pin,LOW);
digitalWrite(relais4pin,LOW);
delay(250);
}
delay(10);
}