const long interval = 10000;
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
Serial.println("renewal");
// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
it mean, it trigger LOW and HIGH for every 10sec.
but How can I manipulate to 0.5sec HIGH and rest of time LOW?
When an interval ends you need to change the value in interval to the number required for the next interval. Something crudely like
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
if (interval == 500) {
interval = 9500;
}
else {
interval = 500;
}
// etc
#include "uTimerLib.h"
unsigned char ledControl = 0;
// LED is LED pin global variable
void blinkLed() {
digitalWrite(LED, ledControl == 0 ? HIGHT : LOW); // You can decide when to blink the led in the period
ledControl = (ledControl + 1) % 20; // 0,5sec hight, 9,5sec low is 1/20th
}
void setup() {
// [..whatever, as set led pin as output]
TimerLib.setInterval_us(blinkLed, 500000); // 500,000 microseconds, as 20 times in 10 seconds
}
// Rest of your program