0x00, 0x00, 0x7F, 0x49, 0x49, 0x36, 0x00, 0x00, // "B"
0x00, 0x00, 0x3E, 0x41, 0x41, 0x22, 0x00, 0x00, // "C"
0x00, 0x00, 0x7F, 0x41, 0x41, 0x3E, 0x00, 0x00, // "D"
0x00, 0x00, 0x7F, 0x49, 0x49, 0x41, 0x00, 0x00, // "E"
0x00, 0x00, 0x7F, 0x48, 0x48, 0x40, 0x00, 0x00, // "F"
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // " "
};
void _shiftOut(int dPin,int cPin,int order,int val){
int i;
for(i = 0; i < 8; i++ ){
digitalWrite(cPin,LOW);
if(order == LSBFIRST){
digitalWrite(dPin,((0x01&(val>>i)) == 0x01) ? HIGH : LOW);
delayMicroseconds(10);
}
else {//if(order == MSBFIRST){
digitalWrite(dPin,((0x80&(val<<i)) == 0x80) ? HIGH : LOW);
delayMicroseconds(10);
}
digitalWrite(cPin,HIGH);
delayMicroseconds(10);
}
}
int main( void)
{
int i, j, k;
unsigned char x;
if(wiringPiSetup() == -1){ //when initialize wiring failed,print messageto screen
printf("setup wiringPi failed !");
return 1;
}
pinMode(dataPin,OUTPUT);
pinMode(latchPin,OUTPUT);
pinMode(clockPin,OUTPUT);
w hile(1){
for(j=0;j<500;j++){// Repeat enough times to display the smiling face a period of
time
x=0x80;
for(i=0;i<8;i++){
digitalWrite(latchPin,LOW);
_shiftOut(dataPin,clockPin,MSBFIRST,pic[i]);// first shift data of line
information to the first stage 74HC959
_shiftOut(dataPin,clockPin,MSBFIRST,~x);//then shift data of column
information to the second stage 74HC959