//in the name of allah
//pin connected to st_cp of 74hc595
int latchpin = 8;
//pin connected to sh_cp of 74hc595
int clockpin = 12;
////pin connected to ds of 74hc595
int datapin = 11;
int num[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6 f};
void setup()
{
//set pins to output so you can control the shift register
pinmode(latchpin, output);
pinmode(clockpin, output);
pinmode(datapin, output);
}
void loop()
{
for(int i = 0; i < 10; i++)
{
for(int j = 0; j <= 20; j++)
{
digitalwrite(latchpin, low);
shiftout(datapin, clockpin, msbfirst, 254);
shiftout(datapin, clockpin, msbfirst, num[i]);
shiftout(datapin, clockpin, msbfirst, ~254);
shiftout(datapin, clockpin, msbfirst, ~num[2]);
digitalwrite(latchpin, high);
delay(4);
digitalwrite(latchpin, low);
shiftout(datapin, clockpin, msbfirst, 253);
shiftout(datapin, clockpin, msbfirst, num[3]);
shiftout(datapin, clockpin, msbfirst, ~253);
shiftout(datapin, clockpin, msbfirst, ~num[i]);
digitalwrite(latchpin, high);
delay(4);
digitalwrite(latchpin, low);
shiftout(datapin, clockpin, msbfirst, 251);
shiftout(datapin, clockpin, msbfirst, num[5]);
shiftout(datapin, clockpin, msbfirst, ~251);
shiftout(datapin, clockpin, msbfirst, ~num[6]);
digitalwrite(latchpin, high);
delay(4);
digitalwrite(latchpin, low);
shiftout(datapin, clockpin, msbfirst, 247);
shiftout(datapin, clockpin, msbfirst, num[9-i]);
shiftout(datapin, clockpin, msbfirst, ~247);
shiftout(datapin, clockpin, msbfirst, ~num[9]);
digitalwrite(latchpin, high);
delay(4);
}
}
}