Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int dataPin = 3;
- int latchPin = 4;
- int clockPin = 5;
- int teller;
- int rijEen = 6;
- int rijTwee = 7;
- int rijDrie = 8;
- int rijVier = 9;
- int pos = 0;
- int i;
- int array1[100];
- int array2[100];
- int array3[100];
- int array4[100];
- void setup() {
- // put your setup code here, to run once:
- pinMode(latchPin, OUTPUT);
- pinMode(dataPin, OUTPUT);
- pinMode(clockPin, OUTPUT);
- pinMode(rijEen,OUTPUT);
- pinMode(rijTwee,OUTPUT);
- pinMode(rijDrie,OUTPUT);
- pinMode(rijVier,OUTPUT);
- digitalWrite(rijEen,LOW);
- digitalWrite(rijTwee,LOW);
- digitalWrite(rijDrie,LOW);
- digitalWrite(rijVier,LOW);
- Random();
- }
- void shift2(byte sData){
- for(i = 0; i < 4; i++){
- digitalWrite(dataPin,(sData>>i)&1);
- digitalWrite(clockPin, HIGH);
- digitalWrite(clockPin, LOW);
- }
- }
- void Random(){
- int Position = 0;
- int value = 0;
- for(teller = 0; teller < 100; teller++){
- value = random(0,255);
- array1[Position] = value;
- value = random(0,255);
- array2[Position] = value;
- value = random(0,255);
- array3[Position] = value;
- value = random(0,255);
- array4[Position] = value;
- Position = Position + 1;
- }
- }
- int valAnimatie(){
- for(teller = 0; teller < 120; teller++){
- shift2(array1[pos]);
- shift2(array1[pos+1]);
- shift2(array1[pos+2]);
- shift2(array1[pos+3]);
- digitalWrite(latchPin,HIGH);
- digitalWrite(latchPin,LOW);
- digitalWrite(rijEen,HIGH);
- delay(2);
- digitalWrite(rijEen,LOW);
- shift2(array2[pos]);
- shift2(array2[pos+1]);
- shift2(array2[pos+2]);
- shift2(array2[pos+3]);
- digitalWrite(latchPin,HIGH);
- digitalWrite(latchPin,LOW);
- digitalWrite(rijTwee,HIGH);
- delay(2);
- digitalWrite(rijTwee,LOW);
- shift2(array3[pos]);
- shift2(array3[pos+1]);
- shift2(array3[pos+2]);
- shift2(array3[pos+3]);
- digitalWrite(latchPin,HIGH);
- digitalWrite(latchPin,LOW);
- digitalWrite(rijDrie,HIGH);
- delay(2);
- digitalWrite(rijDrie,LOW);
- shift2(array4[pos]);
- shift2(array4[pos+1]);
- shift2(array4[pos+2]);
- shift2(array4[pos+3]);
- digitalWrite(latchPin,HIGH);
- digitalWrite(latchPin,LOW);
- digitalWrite(rijVier,HIGH);
- delay(2);
- digitalWrite(rijVier,LOW);
- }
- pos++;
- }
- void loop() {
- // put your main code here, to run repeatedly:
- valAnimatie();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement