EasyManua.ls Logo

Freenove Ultimate Starter Kit - Page 214

Freenove Ultimate Starter Kit
286 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 19 74HC595 & LED Matrix
214
www.freenove.com
support@freenove.com
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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

Table of Contents