====== LEDMatrix ====== **//The Circuit://** {{:hpc0:ledmatrix.jpg?nolink|}} **//The Code://** 1 /********************************************************************** 2 * Filename : LEDMatrix.c 3 * Description : Control LEDMatrix by 74HC595 4 * Author : www.freenove.com 5 * modification: 2019/12/27 6 **********************************************************************/ 7 #include 8 #include 9 #include 10 11 #define dataPin 0 //DS Pin of 74HC595(Pin14) 12 #define latchPin 2 //ST_CP Pin of 74HC595(Pin12) 13 #define clockPin 3 //SH_CP Pin of 74HC595(Pin11) 14 // data of smile face 15 unsigned char pic[]={0x1c,0x22,0x51,0x45,0x45,0x51,0x22,0x1c}; 16 //hardware data for 0-F 17 unsigned char data[]={ 18 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // " " 19 0x00, 0x00, 0x3E, 0x41, 0x41, 0x3E, 0x00, 0x00, // "0" 20 0x00, 0x00, 0x21, 0x7F, 0x01, 0x00, 0x00, 0x00, // "1" 21 0x00, 0x00, 0x23, 0x45, 0x49, 0x31, 0x00, 0x00, // "2" 22 0x00, 0x00, 0x22, 0x49, 0x49, 0x36, 0x00, 0x00, // "3" 23 0x00, 0x00, 0x0E, 0x32, 0x7F, 0x02, 0x00, 0x00, // "4" 24 0x00, 0x00, 0x79, 0x49, 0x49, 0x46, 0x00, 0x00, // "5" 25 0x00, 0x00, 0x3E, 0x49, 0x49, 0x26, 0x00, 0x00, // "6" 26 0x00, 0x00, 0x60, 0x47, 0x48, 0x70, 0x00, 0x00, // "7" 27 0x00, 0x00, 0x36, 0x49, 0x49, 0x36, 0x00, 0x00, // "8" 28 0x00, 0x00, 0x32, 0x49, 0x49, 0x3E, 0x00, 0x00, // "9" 29 0x00, 0x00, 0x3F, 0x44, 0x44, 0x3F, 0x00, 0x00, // "A" 30 0x00, 0x00, 0x7F, 0x49, 0x49, 0x36, 0x00, 0x00, // "B" 31 0x00, 0x00, 0x3E, 0x41, 0x41, 0x22, 0x00, 0x00, // "C" 32 0x00, 0x00, 0x7F, 0x41, 0x41, 0x3E, 0x00, 0x00, // "D" 33 0x00, 0x00, 0x7F, 0x49, 0x49, 0x41, 0x00, 0x00, // "E" 34 0x00, 0x00, 0x7F, 0x48, 0x48, 0x40, 0x00, 0x00, // "F" 35 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // " " 36 }; 37 //used to read all of the data in our "pictures" 38 void _shiftOut(int dPin,int cPin,int order,int val){ 39 int i; 40 for(i = 0; i < 8; i++){ 41 digitalWrite(cPin,LOW); 42 if(order == LSBFIRST){ 43 digitalWrite(dPin,((0x01&(val>>i)) == 0x01) ? HIGH : LOW); 44 delayMicroseconds(10); 45 } 46 else {//if(order == MSBFIRST){ 47 digitalWrite(dPin,((0x80&(val<>=1; // Display the next column 77 delay(1); 78 } 79 } 80 // Go through each part of a data line 81 for(k=0;k>=1; 91 delay(1); 92 } 93 } 94 } 95 } 96 return 0; 97 } This project required two 74HC595s, an LED Matrix board, eight 220ohm resistors, and a ton of jumpers. After setting the circuit up and running the program the LED matrix board first lights up with a smily face then proceeds to have a scrolling display of all numbers from 0 to F. I went into the code and only had to shorten a few comments and rephrase them to be making more sense without the technical jargon. This time the variables were declared outside the loops so I did not have to move them.