![]() |
![]() |
#5 | |
Đệ tử 7 túi
Tham gia ngày: May 2005
Bài gửi: 258
: |
Trích:
code: Code:
#include <18f4520.h> #use delay(clock=12000000) int8 m,i; int8 hang[8]={0,4,2,6,1,5,3,7}; //coi kĩ chỗ này nhé em 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(i=0;i<8;i++) { output_a(hang[i]); sen595(cot1[i]); // sent138(Dong[i]); delay_ms(2); //Tao thoi gian tre } } }
__________________
viết chương trình cho vdk chạy ổn định là cả một vấn đề. |
|
![]() |
![]() |
|
|