Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int SER = 3;
- const int LATCH = 5;
- const int CLK = 4;
- int LedVals[9] = {0,1,2,4,8,16,32,64,128);
- int BacklLedVals[9] = {128,64,32,16,8,4,2,1,0};
- void setup()
- {
- // put your setup code here, to run once:
- pinMode(SER, OUTPUT);
- pinMode(LATCH, OUTPUT);
- pinMode(CLK, 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);
- }
- void loop()
- {
- // put your main code here, to run repeatedly:
- for(int i=0; i<8; i++)
- {
- digitalWrite(LATCH, LOW);
- shiftOut(SER, CLK, MSBFIRST, LedVals[i]);
- digitalWrite(LATCH, HIGH);
- delay (200);
- }
- for(int i=0; i<8; i++)
- {
- digitalWrite(LATCH, LOW);
- shiftOut(SER, CLK, MSBFIRST, BackLedVals[i]);
- digitalWrite(LATCH, HIGH);
- delay (200);
- }
- }
Add Comment
Please, Sign In to add comment