|
- /*
- 基于STC15F104E与74HC138与74HC238实现驱动1个8x8点阵的方法
- 硬件连接:
- P3.0~P3.2口接74HC238,P3.3~P3.5接74HC138
- 74HC238与74HC238,E1脚接VCC,E2、E3接GND,输出脚接8x8点阵。
- By:LscmunaixMG 2017-07-28
- */
- #include "reg51.h"
- #include "intrins.h"
- #include "binary.h" //此头文件内容我就不发了,自行百度。
- unsigned char code image[8] = { //点阵像素数据,可随意修改。
- B00011000,
- B00100100,
- B01000010,
- B10000001,
- B10000001,
- B01000010,
- B00100100,
- B00011000,
- };
- void delay50us() [url=]//@12MHz[/url]
- {
- unsigned char i;
- _nop_();
- i = 22;
- while (--i);
- }
- void GetLED(unsigned char img[8]){
- unsigned char x,y,xx,yy,i;bit b;
- i=16;
- while(i--){
- b=0,x=0,y=0;xx=1;yy=1;
- while(y < 8){
- while(x < 8){
- b = (img[y] & xx) / xx ;
- if(b == 1){
- delay50us();
- P3 = (x | y * 8) & 0x3F;
- }
- xx *= 2;
- x++;
- }
- x=0;
- xx=1;
- y++;
- yy *= 2;
- }
- yy=1;
- y=0;
- }
- }
- void main(){
- while(1){
- GetLED(image);
- }
- }
复制代码
|
|