Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int serial=8; //serial output to shift register
- const int latch=9; //shift register latch pin
- const int clck=10; //shift register clock pin
- int sequence[15 ] = {1, 2, 4, 8, 16, 32, 64, 128, 64, 32, 16, 8, 4, 2, 1};
- int sequence2 [15] = {1,3,7,15,31,63,127,255,127,63,31,15,7,3,1};
- int sequence3 [7]= {129, 66, 36, 24, 36, 66, 129};
- int sequence4 [11 ]={17, 34, 68, 136, 80, 64, 80, 136, 68, 34, 17};
- void setup()
- {
- pinMode (serial, OUTPUT);
- pinMode (latch, OUTPUT);
- pinMode (clck,OUTPUT);
- digitalWrite (latch, LOW); //latch low
- shiftOut (serial, clck, MSBFIRST, B00000000); //shift most significant bit first
- digitalWrite (latch, HIGH); //latch high-show pattern
- }
- void loop()
- {
- for (int i=0; i<15; i++)
- {
- digitalWrite (latch, LOW); //latch low
- shiftOut (serial, clck, MSBFIRST, sequence[i]); //shift most significant bit first
- digitalWrite (latch, HIGH); //latch high-show pattern
- delay (200);
- }
- for (int i=0; i<15; i++)
- {
- digitalWrite (latch, LOW); //latch low
- shiftOut (serial, clck, MSBFIRST, sequence2[i]); //shift most significant bit first
- digitalWrite (latch, HIGH); //latch high-show pattern
- delay (200);
- }
- for (int i=0; i<15; i++)
- {
- digitalWrite (latch, LOW); //latch low
- shiftOut (serial, clck, MSBFIRST, sequence3[i]); //shift most significant bit first
- digitalWrite (latch, HIGH); //latch high-show pattern
- delay (200);
- }
- for (int i=0; i<15; i++)
- {
- digitalWrite (latch, LOW); //latch low
- shiftOut (serial, clck, MSBFIRST, sequence4[i]); //shift most significant bit first
- digitalWrite (latch, HIGH); //latch high-show pattern
- delay (200);
- }
- }
Add Comment
Please, Sign In to add comment