29-04-2012, 10:25 PM | #1 |
Đệ tử 1 túi
Tham gia ngày: Aug 2010
Bài gửi: 22
: |
ai xem giúp e đoạn code quét led matrix với?
chả là e muốn dùng 595 để gửi dữ liệu ra cod.còn 138 để cáp nguồn cho hàng
code e nó đây ạ #include <18f4520.h> #use delay(clock=12000000) int8 m,i; int8 Cot1[8]={0x68,0x6c,0x66,0x63,0xff,0xff,0x60,0x60}; //H{0x36,0x36,0x36,0x7e,0x7e,0x36,0x36,0x36} //A{0x4c,0x6e,0x33,0x33,0x7f,0x7f,0x33,0x33} //D{0x4E,0x26,0x36,0x36,0x36,0x36,0x26,0x4E} //T{0x7e,0x7e,0x48,0x48,0x48,0x48,0x48,0x48} //4{0x68,0x6c,0x66,0x63,0xff,0xff,0x60,0x60} //int8 Dong[]={0b00000000, 0b00000001, 0b00000010, 0b00000011, 0b00000100, 0b00000101, 0b00000110,0b00000111}; //int8 hang[8]={0b000,0b001,0b010,0b011,0b100,0b101,0b110,0b111} ; #define SH PIN_A5 // clock #define DS PIN_A3 // data #define ST PIN_A4 // chot int8 team; void sen595(int8 x) { #bit fla=x.7; for (i=0;i<=7;i++) { if (fla) output_high(DS); //Dich 1 bit vao 74HC595 else output_low(DS); output_high(SH); //Tao xung Clock delay_us(10); output_low(SH); //tao xung Clock x = x<<1; //Dich trai 1 bit cua Data } output_high(ST); //Chot 8 bit cho dau ra output_low(ST); //Chot 8 bit cho dau ra } void main() { int8 i,j; while(1) { for(j=0;j<8;j++) { for(i=0;i<8;i++) { sen595(cot1[i]); output_a(i); delay_ms(10); //Tao thoi gian tre } } } } |
|
|