int ledblue = 8;
int ledred = 7;
int ledyellow = 6;
int ledred2 = 5 ;
int ledblue2 = 4;
int ledyellow2 = 3;
unsigned long moc = 0; // mố c thời gian của chu kỳ ban đầ
u
void setup() {
pinMode(ledblue, OUTPUT);
pinMode(ledred, OUTPUT);
pinMode(ledyellow, OUTPUT);
pinMode(ledred2, OUTPUT);
pinMode(ledblue2, OUTPUT);
pinMode(ledyellow2, OUTPUT);
// put your setup code here, to run once:
}
void loop() {
unsigned long dongho = millis();
unsigned long t = dongho - moc;
if (t < 5000) {
digitalWrite(7, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(3, LOW);
digitalWrite(8, LOW);
digitalWrite(6, LOW);
}
if (t >= 5000 && t < 7000) {
digitalWrite(7, HIGH);
digitalWrite(3, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
}
if (t >= 7000 && t < 12000) {
digitalWrite(8, HIGH);
digitalWrite(5, HIGH);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(4, LOW);
digitalWrite(3, LOW);
}
if (t >= 12000 && t < 14000) {
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(4, LOW);
digitalWrite(3, LOW);
digitalWrite(8, LOW);
}
if (t >= 14000)
moc = dongho;
// put your main code here, to run repeatedly:
}