Code:
// tac gia demon52 #include <16F877A.h> #include <def_877a.h> #device *=16 adc=10 #FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT,NOLVP, NOCPD, NOWRT #use delay(clock=20000000) #include <string.h> /////////// biên dich thì báo lỗi thư viện này (file đính kèm) #define ic595_sclk1 PIN_B0 #define ic595_data1 PIN_B1 #define ic595_lclk1 PIN_B2 #define ic595_sclk2 PIN_B3 #define ic595_data2 PIN_B4 #define ic595_lclk2 PIN_B5 unsigned int8 next=0,lengh_STR; unsigned char count=0; unsigned char welcome[]=" http://codientu.org "; unsigned char *str; #int_timer0 void ngat_time0() { set_timer0(8); count++; if(count==25){ count=0; next++; if(next>=lengh_STR)next=0; } } void Ic74595_Write(char data,char ic,char bits) { signed char count; if(ic==1) { for(count=bits-1;count>=0;count--) { if((( data>>count) & 0x01) ==1) output_high(ic595_data1); else output_low(ic595_data1); output_high(ic595_sclk1); output_low(ic595_sclk1); } output_high(ic595_lclk1); output_low(ic595_lclk1); } if(ic==2) { for(count=bits-1;count>=0;count--) ///////////// các đoạn này ? { if((( data>>count) & 0x01) ==1) output_high(ic595_data2); else output_low(ic595_data2); output_high(ic595_sclk2); output_low(ic595_sclk2); } output_high(ic595_lclk2); output_low(ic595_lclk2); } } void Run_str_RtoL() //////////////////////??? { lengh_str=strlen(str)*6; unsigned char j,temp_font; Ic74595_Write(1,1,1); for(j=next;j<32+next;j++){ Temp_font=font[str[(j%lengh_STR)/With_of_font] -32][j%With_of_font]; Ic74595_Write(temp_font,2,8); delay_us(500); Ic74595_Write(0,1,1); } } void main (){ TRISB=0x00; enable_interrupts(int_timer0); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256); enable_interrupts(global); set_timer0(8); str=welcome; while(1){ Run_str_RtoL(); } }
http://www.mediafire.com/download/zk...X8_PIC_CCS.rar
Comment