So I'm trying to design a circuit to blink out 10 randomly generated numbers in a row on the Pico onboard LED, with a break between each number. Being that I know very little about java, it's been a bit of a struggle. I've been using combinations of setTimeout and setInterval, but I can't seem to figure out how to blink the numbers one after the other.
I've come to the point where I'm using an array to generate concurrent timers as per below. Both g and rando are Uint8ClampedArray(10). h is declared globally but doesn't work any better locally. I've started with 4 to keep it simple.
for (h=0;h<4;h++) {
console.log(h);
g[h] = setTimeout('console.log(rando[h]);', rando[h]*400);
}
outputs the following:
new Uint8ClampedArray([16, 17, 1, 9, 8, 7, 15, 18, 19, 1])
0
1
2
3 //output of console.log(h) during the loop
8 //output of what should be the first 4 numbers of the rando array.
8
8
8
WTF am I doing wrong and/or what am I missing to get this thing to blink out 10 random numbers with a space in between?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
So I'm trying to design a circuit to blink out 10 randomly generated numbers in a row on the Pico onboard LED, with a break between each number. Being that I know very little about java, it's been a bit of a struggle. I've been using combinations of setTimeout and setInterval, but I can't seem to figure out how to blink the numbers one after the other.
I've come to the point where I'm using an array to generate concurrent timers as per below. Both g and rando are Uint8ClampedArray(10). h is declared globally but doesn't work any better locally. I've started with 4 to keep it simple.
outputs the following:
WTF am I doing wrong and/or what am I missing to get this thing to blink out 10 random numbers with a space in between?
Any help would be appreciated