loading

Doubt on coding?

Hi,

I am slowly beginning to understand coding better because of your projects. Thanks a lot for your amazing lessons.

void loop() {



// Pick a random number between 0 and 3

int range = random(4);

What does this mean? I am not understanding this line of code.


randofo1 month ago

This is setting the variable "range" to be equal to a random number between 0 and 3. The Arduino counts 0 as a number and counts up from there.

For instance, if you were to change it to random(8), it would pick a random number between 0 and 7.

Siddhaanth Iyer (author)  randofo1 month ago

Thanks A lot randofo