Advertisement
inagantid20

random lights- multiple LED Dice together

Jun 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. /*
  2. * Divya Inaganti
  3. * June 23, 2017
  4. * random lights- multiple LED Dice together
  5. */
  6. const int datapin = 11;
  7. const int latchpin = 12;
  8. const int clockpin = 13;
  9.  
  10. int light[7]= {2, 4, 8, 16, 32, 64, 128};
  11. int bar[7]= {2, 6, 14, 30, 62, 126, 254};
  12. //int bar[7]= {0, 1, 3, 7, 15, 31, 63, 127, 255};
  13.  
  14.  
  15. void setup()
  16. {
  17. pinMode(datapin, OUTPUT);
  18. pinMode(latchpin, OUTPUT);
  19. pinMode(clockpin, OUTPUT);
  20.  
  21. digitalWrite(latchpin, LOW);
  22. shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  23. shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  24. shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  25. shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  26. shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  27. shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  28. digitalWrite(latchpin, HIGH);
  29. delay(1000);
  30. digitalWrite(latchpin, LOW);
  31. shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  32. shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  33. shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  34. shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  35. shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  36. shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  37. digitalWrite(latchpin, HIGH);
  38. delay(1000);
  39. }
  40. void loop()
  41. {
  42.  
  43. digitalWrite(latchpin, LOW);
  44. shiftOut(datapin, clockpin, MSBFIRST, random (2, 255));
  45. shiftOut(datapin, clockpin, MSBFIRST, random (2, 255));
  46. shiftOut(datapin, clockpin, MSBFIRST, random (2, 255));
  47. shiftOut(datapin, clockpin, MSBFIRST, random (2, 255));
  48. shiftOut(datapin, clockpin, MSBFIRST, random (2, 255));
  49. shiftOut(datapin, clockpin, MSBFIRST, random (2, 255));
  50. digitalWrite(latchpin, HIGH);
  51. delay(50);
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement