官方板, 3 595 run num , same
//arduino d1 , esp8266 generic
int latchPin = 5;//st_cp pin 12
int clockPin = 16;//sh_cp pin 11
int dataPin = 4;
#define uc unsigned char
uc table[]={~0x01,0x0a,~0X68,~0xE0,~0xB4,~0xA2,~0x02,~0x91,~0x00,~0xa0,~0x40,~0x00};
void setup()
{
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
uc n[8];
long t;
uc q[]={3,2,1,0,7,6,5,4};
fix_tab();
while(1){
for(int j=0;j<9999;j++){
// n[7]=(j/10000000)%10;
// n[6]=(j/1000000)%10;
// n[5]=(j/100000)%10;
// n[4]=(j/10000)%10;
n[3]=(j/1000)%10;
n[2]=(j/100)%10;
n[1]=(j/10)%10;
n[0]=(j/1)%10;
n[7]=n[3];
n[6]=n[2];
n[5]=n[1];
n[4]=n[0];
Serial.println(j);
t=millis()+5;
while(1)
{
if(millis()>t) break;
for(int i=0;i<8;i++){
digitalWrite(latchPin, LOW);// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, ~(1<<q[i]));//take the latch pin high so the LEDs will light up:
shiftOut(dataPin, clockPin, MSBFIRST,table[n[i]]);//take the latch pin high so the LEDs will light up:
shiftOut(dataPin, clockPin, MSBFIRST,table[n[i]]);//take the latch pin high so the LEDs will light up:
digitalWrite(latchPin, HIGH);// pause before next value:
}
}
}
}
}
void fix_tab()
{
uc i;
//xdata uc table[]={~0x01,0x0a,~0X68,~0xE0,~0xB4,~0xA2,~0x02,~0x91,~0x00,~0xa0,~0x40,~0x00};
for(i=0;i<10;i++){ table[i]=0; }
table[0]=~((1<<2)|(1<<0)|(1<<5)|(1<<4)|(1<<3)|(1<<1));
table[1]=~((1<<0)|(1<<5));
table[2]=~((1<<2)|(1<<0)|(1<<6)|(1<<3)|(1<<4));
table[3]=~((1<<2)|(1<<0)|(1<<5)|(1<<4)|(1<<6));
table[4]=~((1<<1)|(1<<0)|(1<<6)|(1<<5));
table[5]=~((1<<2)|(1<<1)|(1<<6)|(1<<5)|(1<<4));
table[6]=~((1<<2)|(1<<3)|(1<<6)|(1<<5)|(1<<4)|(1<<1));
table[7]=~((1<<1)|(1<<2)|(1<<0)|(1<<5));
table[8]=~((1<<2)|(1<<3)|(1<<0)|(1<<6)|(1<<1)|(1<<5)|(1<<4));
table[9]=~((1<<2)|(1<<1)|(1<<0)|(1<<6)|(1<<5)|(1<<4));
}
留言