I'm just getting started with this Arduino and c++ language. I know basic and some advanced electronics. The only thing I know as far as programming is BASIC and a few PLC and industrial machine specific languages. After looking at some examples I kinda understand how to write in c. But there is a few things confusing me at the moment.
I wrote this:
// Random light flasher
void setup()
// set random number
{randomSeed(1);
// set outputs
{for (int led = 3; led <= 12; led++)
{pinMode(led, OUTPUT);}}}
void loop()
//setup rand and tell it to turn a pin on and then off
{int rand = random(3, 13);
digitalWrite(rand, HIGH);
delay(100);
digitalWrite(rand, LOW);}
I have a shield i made that just has 10 LEDs connected to pins 3-12.
My question is why is it when i tell the random to do (3,12) it never lights pin 12. I am telling it that the max number is 12 so 12 should come up and light the last LED on pin 12. But as you can see in the actual program i have it set to 13. Am I missing something? I figure when I tell it that the max is 12 that 12 is allowed to be picked as a random number but nothing higher then 12. It's outputting a 3 as a min but when I tell it 12 as a max it never outputs a 12. Am I missing something here?
Thanks.