#include "ArduinoTrace.h"
bool R,G,Y;
//======================== SETUP ===========================//
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
//======================== LOOP ===========================//
void loop() {
// put your main code here, to run repeatedly:
static unsigned long pm=0;
if((millis()-pm)>=100)
{
pm=millis();
Task1();
}
}
//======================== TASK1 ===========================//
void Task1()
{
static int step=1;
static int counter=0;
switch (step)
{
case 1: //INIT
G=1;
digitalWrite(8, HIGH);
counter=50;
step=2;
break;
case 2: //G_ON
counter--;
if(counter==0)
{
G=0;
Y=1;
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
counter=20;
step=3;
}
break;
case 3: //Y_ON
counter--;
if(counter==0)
{
Y=0;
R=1;
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
counter=40;
step=4;
}
break;
case 4: //R_ON
counter--;
if(counter==0)
{
Y=1;
digitalWrite(9, HIGH);
counter=20;
step=5;
}
break;
case 5: //R_ON Y_ON
counter--;
if(counter==0)
{
Y=0;
R=0;
G=1;
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(8, HIGH);
counter=50;
step=2;
}
break;
}
}
//========================================================//