samedi 12 décembre 2020

Arduino Loop random amount of time

I need help looping a loop random amount of time. For example:

  for (int i = 0; i <= 10; i++) {
     //Blah blah code
  }

This, I believe loops it 10 times. I want it to loop a random amount of times so I tried this:

  for (int i = 0; i <= random(0,1000); i++) {
     //Blah blah code
  }

This hasn't worked for me, and it only picks randomly when I first power the arduino. When I close it and try it again, it loops it the same amount of times as before, and so forth. My question is, what am I doing wrong?




Aucun commentaire:

Enregistrer un commentaire