Hi gays,
I wrote a simple code for flash lights ,
want to flash two lights respective and than flash together.
And you can see the code for detalis:
int led1 =12;
int led2 =13;
void setup() {
// put your setup code here, to run once:
for(int i=1;i<6;i++)
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int delaytime =100;
for(int i=1;i<20;i++){
if(i<10){
digitalWrite(led1,HIGH);
delay(delaytime);
digitalWrite(led1,LOW);
delay(delaytime);
digitalWrite(led2,HIGH);
delay(delaytime);
digitalWrite(led2,LOW);
delay(delaytime);
}
else{
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
delay(50);
digitalWrite(led2,LOW);
digitalWrite(led2,LOW);
delay(50);
}
}
}
But the result is so strange.
One of the light is still turn on ,another is OK(flashing);the program running at the second part.
This the the vedio:手机QQ视频 20160303213739 - YouTube
I dont know why and I can not explain it.
Doe anyone who know it?