Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. int dataPin = 3;
  2. int latchPin = 4;
  3. int clockPin = 5;
  4. int teller;
  5. int rijEen = 6;
  6. int rijTwee = 7;
  7. int rijDrie = 8;
  8. int rijVier = 9;
  9. int pos = 0;
  10. int i;
  11. int array1[100];
  12. int array2[100];
  13. int array3[100];
  14. int array4[100];
  15.  
  16.  
  17. void setup() {
  18. // put your setup code here, to run once:
  19. pinMode(latchPin, OUTPUT);
  20. pinMode(dataPin, OUTPUT);
  21. pinMode(clockPin, OUTPUT);
  22. pinMode(rijEen,OUTPUT);
  23. pinMode(rijTwee,OUTPUT);
  24. pinMode(rijDrie,OUTPUT);
  25. pinMode(rijVier,OUTPUT);
  26. digitalWrite(rijEen,LOW);
  27. digitalWrite(rijTwee,LOW);
  28. digitalWrite(rijDrie,LOW);
  29. digitalWrite(rijVier,LOW);
  30. Random();
  31. }
  32.  
  33. void shift2(byte sData){
  34. for(i = 0; i < 4; i++){
  35. digitalWrite(dataPin,(sData>>i)&1);
  36. digitalWrite(clockPin, HIGH);
  37. digitalWrite(clockPin, LOW);
  38. }
  39. }
  40.  
  41. void Random(){
  42. int Position = 0;
  43. int value = 0;
  44. for(teller = 0; teller < 100; teller++){
  45. value = random(0,255);
  46. array1[Position] = value;
  47. value = random(0,255);
  48. array2[Position] = value;
  49. value = random(0,255);
  50. array3[Position] = value;
  51. value = random(0,255);
  52. array4[Position] = value;
  53. Position = Position + 1;
  54. }
  55. }
  56.  
  57. int valAnimatie(){
  58. for(teller = 0; teller < 120; teller++){
  59.  
  60. shift2(array1[pos]);
  61. shift2(array1[pos+1]);
  62. shift2(array1[pos+2]);
  63. shift2(array1[pos+3]);
  64. digitalWrite(latchPin,HIGH);
  65. digitalWrite(latchPin,LOW);
  66. digitalWrite(rijEen,HIGH);
  67. delay(2);
  68. digitalWrite(rijEen,LOW);
  69. shift2(array2[pos]);
  70. shift2(array2[pos+1]);
  71. shift2(array2[pos+2]);
  72. shift2(array2[pos+3]);
  73. digitalWrite(latchPin,HIGH);
  74. digitalWrite(latchPin,LOW);
  75. digitalWrite(rijTwee,HIGH);
  76. delay(2);
  77. digitalWrite(rijTwee,LOW);
  78. shift2(array3[pos]);
  79. shift2(array3[pos+1]);
  80. shift2(array3[pos+2]);
  81. shift2(array3[pos+3]);
  82. digitalWrite(latchPin,HIGH);
  83. digitalWrite(latchPin,LOW);
  84. digitalWrite(rijDrie,HIGH);
  85. delay(2);
  86. digitalWrite(rijDrie,LOW);
  87. shift2(array4[pos]);
  88. shift2(array4[pos+1]);
  89. shift2(array4[pos+2]);
  90. shift2(array4[pos+3]);
  91. digitalWrite(latchPin,HIGH);
  92. digitalWrite(latchPin,LOW);
  93. digitalWrite(rijVier,HIGH);
  94. delay(2);
  95. digitalWrite(rijVier,LOW);
  96. }
  97. pos++;
  98. }
  99.  
  100.  
  101. void loop() {
  102. // put your main code here, to run repeatedly:
  103.  
  104. valAnimatie();
  105.  
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement