light delay light

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;
 }
}

Tried doing digitalWrite but it gave me an error that said I needed to define digitalWrite that is why I changed it.

benkishpaugh:
Tried doing digitalWrite but it gave me an error that said I needed to define digitalWrite that is why I changed it.

If you say so.
I'd rather see the code you say didn't compile.
In code tags this time, please.

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]

[/code]

Not sure if this makes it better or worse what do you think?

if (digitalRead(2)==HIGH) {
    TimerA = millis() , digitalWrite(4);}
  if (millis() - TimerA >= 1000UL) {
    digitalWrite(5);}
  if (digitalRead(3)==HIGH) {
    TimerB = millis() , digitalWrite(5);}
  if (millis() - TimerB >= 1000UL) {
    digitalWrite(4);}
    TimerA = millis() , digitalWrite(4);

I suspect that this is not doing what you want.

{
    TimerA = millis();
    digitalWrite(4);
}

might do what you want, but I have not studied your program.

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. :confused:

It actually will not compile now

Please post "it"

Thank you for the help. :slight_smile: