Advertisement
baldengineer

Init a variable to multiple of 12

Dec 17th, 2014
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. void setup() {
  2.  Serial.begin(9600);
  3.  randomSeed(analogRead(0));
  4.  int factorOf12 = random(0,1024);
  5.  int x=1;
  6.  while(factorOf12 % 12 != 0) {
  7.    factorOf12 = random(0,1024);
  8.    x++;
  9.  }
  10.  Serial.print("Got: "); Serial.println(factorOf12);
  11.  Serial.print("Took: "); Serial.print(x); Serial.println(" tries");
  12. }
  13.  
  14. void loop() {
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement