the green/blue/white collorcode is fade a led random like a soft star effect. It's working thats ok.
But you see he will first execute lcdscreen, green, than blue and at last white light .
and thats what I dont like 2e green, 3e blue and last white...
I like that the execute of the collor random is
like this : exmp.
lcd, white, green, blue or
lcd, blue white green
But how can I manage that, that random collor void....
int pick( int a, int b)
{
return random(2) ? a : b ;
}
void loop() {
static int next;
lcdscreen();
switch (next) {
case 0: redlight(); next= pick( 1,2); break;
case 1: bluelight(); next= pick( 0,2); break;
case 2: greenlight(); next= pick( 0,1); break;
}
}
if you don't want It to produce the same pseudo-random sequence each time you boot/power it-- see random() - Arduino Reference
But hmm can you little explain whats happening in that code, I am a little blocked...
John added a new function, to pick a random number, called pick(). Then, in loop, there is a new variable to hold the random number, next.
The switch statement calls a function, based on the value in next, and then assigns a new value to next, by calling the pick() function with some limits on the random value that can be returned.
John added a new function, to pick a random number, called pick(). Then, in loop, there is a new variable to hold the random number, next.
The switch statement calls a function, based on the value in next, and then assigns a new value to next, by calling the pick() function with some limits on the random value that can be returned.
Oeps I see it, yea sorry it was lazzy of me, copy past.... and forgot delete that voids..... only
void loop(){
name();
name2();
}