AWOL:
But, as you can see, you've introduced a delay into a blink without delay.
You've got me ![]()
How to do it without it?
On the other hands, thank you for the tip, now both LEDs are working!!!
const int tick = 2;
const int tock = 12;
int tickState = LOW;
int tockState = LOW;
unsigned long previousMillis = 0;
void setup() {
pinMode(tick, OUTPUT);
pinMode(tock, OUTPUT);
Serial.begin(9600);
}
void loop() {
unsigned long currentMillis = millis();
int clockspeed = map(analogRead(0), 0, 1024, 1000, 10);
if (currentMillis - previousMillis >= clockspeed) {
previousMillis = currentMillis;
if (tickState = HIGH) {
tickState = HIGH;
digitalWrite(tick, tickState);
delay(7);
digitalWrite(tick, LOW);
int comparator = random (0,100);
int density = map(analogRead(1), 0, 1024, 10, 100);
if (comparator < density) {
digitalWrite(tock, HIGH);
delay(7);
digitalWrite(tock, LOW);
} else {
tockState = LOW;
}
} else {
tickState = LOW;
}
Serial.println(clockspeed);
}
}