top of page
Animation Random Leds + Potentiomètre
int nbAleatoire = 0, nbAleatoire2 = 0, y = 0, potPin = 0, val = 0;
void setup() {
for(int x=0; x<=10; x++)
pinMode(x, OUTPUT);
}
void loop() {
val = analogRead(potPin);
const int MAX = 10, MIN = 1, MAX2 = 3, MIN2 = 1;
nbAleatoire = (rand() % (MAX - MIN + 1)) + MIN;
nbAleatoire2 = (rand() % (MAX2 - MIN2 + 1)) + MIN2;
if(nbAleatoire2 == 1)
{
y=val;
}
else if(nbAleatoire2 == 2)
{
y=val;
}
else if(nbAleatoire2 == 3)
{
y=val;
}
digitalWrite(nbAleatoire, 1);
delay(y+15);
digitalWrite(nbAleatoire, 0);
}
bottom of page