Below is my code I am trying to push button1(STR) to turn on light1(SCR) then after 10sec delay turn on light2(COM), then push button2(STO) to turn off light2(COM) then after delay turn off light1(SCR). Is there a problem with my code?
int STR = LOW;
int STO = LOW;
int SCR = LOW;
int COM = LOW;
void setup() {
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
void loop() {
STR = digitalRead(2);
STO = digitalRead(3);
unsigned long TimerA;
unsigned long TimerB;
if (STR == HIGH) {
TimerA = millis();
SCR == HIGH;
}
if (millis() - TimerA >= 1000UL) {
COM == HIGH;
}
if (STO == HIGH) {
TimerB = millis();
COM == LOW;
}
if (millis() - TimerB >= 1000UL) {
SCR == LOW;
}
}
I found the original code and tried using it but kept getting errors so I kept changing till the errors went away and ended up with the mess I showed before. I am not very familiar with arduino syntax still in early stages of learning but done with the book I got with the kit.
unsigned long TimerA "ALWAYS use unsigned long for timers..."
unsigned long TimerB
if digitalReadA==Down
then TimerA= millis() , digitalWriteA ON
if millis()-TimerA >= 15000UL
then digitalWriteA Off
if digitalReadB==Down
then TimerB= millis() , digitalWriteB ON
if millis()-TimerB >= 15000UL
then digitalWriteB Off [code]
It actually will not compile now. My first post explains what I was trying to accomplish and has all the code I developed and it did not do anything wiring is correct but no magic.