Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Manvi Mittal
- * 5 shift registers
- */
- const int ser = 17;
- const int latch = 18;
- const int clk = 19;
- int lights [7] = {2, 4, 8, 16, 32, 64, 128};
- int bar [7] = {3, 7, 15, 31, 63, 127, 255};
- void setup() {
- // put your setup code here, to run once:
- pinMode (ser, OUTPUT);
- pinMode (latch, OUTPUT);
- pinMode (clk, OUTPUT);
- lightUp (B11111111, B11111111, B11111111, B11111111, B11111111); // scroll down for lightUp function
- delay (100);
- }
- void loop()
- {
- // put your main code here, to run repeatedly:
- for (int i = 0; i < 7; i++)
- {
- lightUp (lights[i], B0000000, B0000000, B0000000, B0000000);
- delay (100);
- }
- for (int i = 0; i < 7; i++)
- {
- lightUp (B0000000, lights[i], B0000000, B0000000, B0000000);
- delay (100);
- }
- for (int i = 0; i < 7; i++)
- {
- lightUp (B0000000, B0000000, lights[i], B0000000, B0000000);
- delay (100);
- }
- for (int i = 0; i < 7; i++)
- {
- lightUp (B0000000, B0000000, B0000000, lights[i], B0000000);
- delay (100);
- }
- for (int i = 0; i < 7; i++)
- {
- lightUp (B0000000, B0000000, B0000000, B0000000, lights[i]);
- delay (100);
- }
- for (int i = 0; i < 7; i++)
- {
- lightUp (bar[i], B0000000, B0000000, B0000000, B0000000);
- delay (100);
- }
- for (int i = 0; i < 7; i++)
- {
- lightUp (B11111111, bar[i], B0000000, B0000000, B0000000);
- delay (100);
- }
- for (int i = 0; i < 7; i++)
- {
- lightUp (B11111111, B11111111, bar[i], B0000000, B0000000);
- delay (100);
- }
- for (int i = 0; i < 7; i++)
- {
- lightUp (B11111111, B11111111, B11111111, bar[i], B0000000);
- delay (100);
- }
- for (int i = 0; i < 7; i++)
- {
- lightUp (B11111111, B11111111, B11111111, B11111111, bar[i]);
- delay (100);
- }
- for (int i = 0; i < 66; i++)
- {
- lightUp (random (2, 255), random (2, 255), random (2, 255), random (2, 255), random (2, 255));
- delay (100);
- }
- }
- void lightUp (int byte1, int byte2, int byte3, int byte4, int byte5)
- {
- digitalWrite (latch, LOW);
- shiftOut (ser, clk, MSBFIRST, byte1);
- shiftOut (ser, clk, MSBFIRST, byte2);
- shiftOut (ser, clk, MSBFIRST, byte3);
- shiftOut (ser, clk, MSBFIRST, byte4);
- shiftOut (ser, clk, MSBFIRST, byte5);
- digitalWrite (latch, HIGH);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement