Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int SER = 8; // Serial Output to Shift Register
- const int LATCH = 9; // Shift Register Latch Pin
- const int CLK = 10; // Shift Register Clock Pin
- int x;
- int y;
- int dly = 500;
- int seq[]={130,217,211,178,115,123,194,507,242};
- void setup() {
- // put your setup code here, to run once:
- pinMode(SER, OUTPUT);
- pinMode(LATCH, OUTPUT);
- pinMode(CLK, OUTPUT);
- digitalWrite(LATCH, LOW);
- digitalWrite(LATCH,HIGH);
- }
- void dec()
- {
- digitalWrite(LATCH, LOW);
- shiftOut(SER, CLK, MSBFIRST, 4);
- digitalWrite(LATCH,HIGH);
- }
- void one()
- {
- digitalWrite(LATCH, LOW);
- shiftOut(SER, CLK, MSBFIRST, 130);
- digitalWrite(LATCH,HIGH);
- }
- void two()
- {
- digitalWrite(LATCH, LOW);
- shiftOut(SER, CLK, MSBFIRST, 217);
- digitalWrite(LATCH,HIGH);
- }
- void three()
- {
- digitalWrite(LATCH, LOW);
- shiftOut(SER, CLK, MSBFIRST, 211);
- digitalWrite(LATCH,HIGH);
- }
- void four()
- {
- digitalWrite(LATCH, LOW);
- shiftOut(SER, CLK, MSBFIRST, 178);
- digitalWrite(LATCH,HIGH);
- }
- void five()
- {
- digitalWrite(LATCH, LOW);
- shiftOut(SER, CLK, MSBFIRST, 115);
- digitalWrite(LATCH,HIGH);
- }
- void six()
- {
- digitalWrite(LATCH, LOW);
- shiftOut(SER, CLK, MSBFIRST, 123);
- digitalWrite(LATCH,HIGH);
- }
- void seven()
- {
- digitalWrite(LATCH, LOW);
- shiftOut(SER, CLK, MSBFIRST, 194);
- digitalWrite(LATCH,HIGH);
- }
- void eight()
- {
- digitalWrite(LATCH, LOW);
- shiftOut(SER, CLK, MSBFIRST, 507);
- digitalWrite(LATCH,HIGH);
- }
- void nine()
- {
- digitalWrite(LATCH, LOW);
- shiftOut(SER, CLK, MSBFIRST, 242);
- digitalWrite(LATCH,HIGH);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- x = random(1,10);
- for (y = 1; y <= 9; y++)
- {
- //seq[x];
- //delay(100);
- switch (y)
- {
- case 1:
- one();
- delay(dly);
- break;
- case 2:
- two();
- delay(dly);
- break;
- case 3:
- three();
- delay(dly);
- break;
- case 4:
- four();
- delay(dly);
- break;
- case 5:
- five();
- delay(dly);
- break;
- case 6:
- six();
- delay(dly);
- break;
- case 7:
- seven();
- delay(dly);
- break;
- case 8:
- eight();
- delay(dly);
- break;
- case 9:
- nine();
- delay(dly);
- break;
- }
- //
- // case dec:
- // dec();
- // delay(dly);
- // break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement