Ok, found an example, where the blink time and the interval are separated :
const int tick = 2;
const int trigger_length = 7;
byte tickState = LOW;
unsigned long currentMillis = 0;
unsigned long previousMillis = 0;
void setup() {
Serial.begin(9600);
pinMode(tick, OUTPUT);
}
void loop() {
currentMillis = millis();
update_tick();
}
void update_tick() {
if (tickState == LOW) {
Serial.println("LOW");
int clockspeed = map(analogRead(0), 0, 1024, 1000, 7);
if ((unsigned long) currentMillis - previousMillis >= clockspeed) {
tickState = HIGH;
digitalWrite(tick, tickState);
previousMillis += clockspeed;
}
}
else {
Serial.println("HIGH");
if ((unsigned long) currentMillis - previousMillis >= trigger_length) {
tickState = LOW;
digitalWrite(tick, tickState);
previousMillis += trigger_length;
}
}
}
Me happy :D:D:D