long previousMillis = 0;
void loop () {
flash();
}
void flash () {
if (millis() - previousMillis > 840) {
previousMillis = millis();
digitalWrite(NoSoundLed, LOW);
digitalWrite(NotifyLed, HIGH);
delay(120);
digitalWrite(NotifyLed, LOW);
delay(120);
digitalWrite(NotifyLed, HIGH);
delay(120);
digitalWrite(NotifyLed, LOW);
delay(120);
digitalWrite(NoSoundLed, HIGH);
delay(120);
digitalWrite(NoSoundLed, LOW);
delay(120);
digitalWrite(NoSoundLed, HIGH);
delay(120);
digitalWrite(NoSoundLed, LOW);
}
}
if ((millis() % 1000) > 500) digitalWrite(Pin, HIGH);
else digitalWrite(Pin, LOW);
void setup() {
pinMode(13, OUTPUT);
}
unsigned int millisCounter = 0;
void migalka(void)
{
millisCounter = millis() % 8400;
if(millisCounter < 1200 )
{digitalWrite(13,1);}
else
if(millisCounter < 2400)
{digitalWrite(13,1);}
else
if(millisCounter < 3600)
{digitalWrite(13,1);}
else
if(millisCounter < 4800)
{digitalWrite(13,0);}
else
if(millisCounter < 5200)
{digitalWrite(13,0);}
else
if(millisCounter < 6400)
{digitalWrite(13,1);}
else
if(millisCounter < 7200)
{digitalWrite(13,1);}
else
{digitalWrite(13,0);}
}
/*основной цикл*/
void loop() {
migalka();
}
delay
можно переписать вот так:long previousMillis = millis();
while (true) {
if (millis() - previousMillis >= 120) {
break;
}
previousMillis = millis();
}
for (int i = 0; i < 1000000; i++) { ; }
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
digitalWrite(NotifyLed, HIGH);
//TODO If delay is too low, use Ctrl+C Ctrl+V