Hello. I found a code online for controlling 6 LEDs. There's a section for lighting them in a loop, and it does the LEDs in the same order every time. I want to make it choose them randomly. I think I need something like random(1,6), but I'm not sure that's correct or how to add it. I'm completely new to this. Any help would be greatly appreciated.
1 2 3 4 5 6 7 8 9 10 11
// EXCITED =========================================
// + Flash each LED, one at a time, six times in a row
case EXCITED:
for(int j=0; j<6; j++) {
for(int i=1; i<=6; i++) {
turnOn(i);
delay(50);
turnOff(i);
delay(50);
}
}
isn't it too early to call that?
i know <random> library is introduced in C++11, which provides extensive random number support. but for simple cases srand/rand still relevant. many best selling(recent)books support that:
C++ How to program - Deitel 8th ed. (2011) p207
starting out C++ - Tonny Gaddis 8th ed.(2014) p127
C++ programming - DS Mallic 6th ed.(2012) p275
Absolute C++ - Walter Savitch 5th ed.(2012) p110