Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int seqNum [10] = { 252, 80, 186, 218, 86, 206, 238, 88, 254, 222 };
- int LedVals [9] = {0,1,2,4,8,16,32,64,128,};
- int BackLedVals[9] = {128, 64, 32, 16, 8, 4, 2, 1, 0};
- int newLED [8] = { 1, 3, 7, 15, 31, 63, 127, 255};
- int backLedVals [8] = {255, 127, 63, 31, 15, 7, 3, 1};
- bool lastButton = false;
- bool currentButton =false;
- int randNum;
- const int buttPin = 8;
- const int SER = 9;
- const int LATCH = 10;
- const int CLK = 11;
- const int SER2 = 2;
- const int LATCH2 = 3;
- const int CLK2 = 4;
- int count = 0;
- void setup() {
- // put your setup code here, to run once:
- pinMode (SER, OUTPUT);
- pinMode (LATCH, OUTPUT);
- pinMode (CLK, OUTPUT);
- pinMode (SER2, OUTPUT);
- pinMode (LATCH2, OUTPUT);
- pinMode (CLK2, OUTPUT);
- digitalWrite (LATCH, LOW);
- shiftOut (SER, CLK, MSBFIRST, B11111111);
- digitalWrite (LATCH, HIGH);
- delay (200);
- digitalWrite (LATCH, LOW);
- shiftOut (SER, CLK, MSBFIRST, B00000000);
- digitalWrite (LATCH, HIGH);
- randomSeed(analogRead(0));
- digitalWrite (LATCH2, LOW);
- shiftOut (SER2, CLK2, MSBFIRST, B11111111);
- digitalWrite (LATCH2, HIGH);
- delay (200);
- digitalWrite (LATCH2, LOW);
- shiftOut (SER2, CLK2, MSBFIRST, B00000000);
- digitalWrite (LATCH2, HIGH);
- Serial.begin (9600);
- }
- boolean debounce (boolean last)
- {
- boolean current = digitalRead(buttPin);
- if (last != current)
- {
- delay(5);
- current = digitalRead(buttPin);
- }
- return current;
- randomSeed(analogRead(0));
- }
- void effect (int seq [])
- {
- for (int i = 0; i < 10; i++)
- {
- digitalWrite (LATCH, LOW);
- shiftOut (SER, CLK, MSBFIRST, seq[i]);
- digitalWrite (LATCH, HIGH);
- delay (100);
- }
- }
- void loop()
- {
- currentButton = debounce (lastButton);
- if (lastButton == LOW && currentButton == HIGH)
- {
- randNum = random (1,11);
- Serial.println (randNum);
- digitalWrite(LATCH2, LOW);
- shiftOut (SER2, CLK2, MSBFIRST, seqNum [randNum]);
- digitalWrite (LATCH2, HIGH);
- // }
- delay(500);
- }
- switch(randNum)
- {
- case 1 :
- effect (BackLedVals);
- break;
- }
- lastButton = currentButton;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement