䕃ӊ䇈
ё0x55H(0101 0101B)0xAAH(1010 1010B)P1ēճ0ďԎԨĐԅճԅ΄Ԥd
⏙
8P1ēёġ#include \"reg51.h\"
typedef unsigned char BYTE; typedef unsigned int WORD; BYTE ai,di;
void Delay(WORD n) //ё{
WORD x; while(n--) {
x=5000; while(x--); } }
void main() //ё{
SP=0x60; di=0x55; while(1) { //P1=di; //Delay(100); //di =~di; for (ai=100;ai>=2;ai-=2) { P1=di; Delay(ai); di =~di; } for (ai=2;ai<=100;ai+=2) { P1=di; Delay(ai); di =~di; } } }
4
2.ⷕㅵⱘ⼎䆒䅵
⹀ӊ⬉䏃䆒䅵
DԅԨӦc4cՎԨcD
Ԩԉюd͐J7J2ďA8—A11ĐēӦP2.0-P2.34dJ14J15ēP0ѻխď74HC573ѻēёΩĐd
D
䕃ӊ䇈
1.խζ
⼎ヺ
䰇↉ⷕ
䰈↉ⷕ
⼎ヺ
䰇↉ⷕ
䰈↉ⷕ
0 C0H 3FH C C6H 39H 1 F9H 06H A1H 5EH 2 A4H 5BH E 86H 79H 3 B0H 4FH F 8EH 71H 4 99H 66H P 8CH 73H 5 92H 6H U C1H 3EH 6 82H 7H r CEH 31H 7 F8H 07H Y 91H 6EH 8 80H 7FH H 89H 76H 9 90H 6FH L C7H 38H A 88H 77H ҂ 00H FFH B 83H 7CH ♁ FFH 00H
2.ёēωѻխēҶԎ0-Fԅd
5
⏙
#include \"reg51.h\" #include \"intrins.h\" #include\"absacc.h\" #include\"math.h\"
typedef unsigned char BYTE; typedef unsigned int WORD;
/* LEDԙ */
#define led_data XBYTE[0x6000] //BYTE led_w; BYTE
led_dm[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//0:0xc0,1:0xf9,2:0xa4,3:0xb0,4:0x99,5:0x92,6:0x82,7:0xf8,8:0x80,9:0x90BYTE di;
/*****************LED********************/void LED_crt(BYTE val) {
led_data=led_dm[val];//0:0xc0,1:0xf9,2:0xa4,3:0xb0,4:0x99,5:0x92,6:0x82,7:0xf8,8:0x80,9:0x90 P2 |= 0xff; P2 &= led_w; led_w>>=1; if (led_w==0x0f) led_w=0xf7; }
void Delay(WORD n) {
WORD x; while(n--) {
x=500;
while(x--); } }
void main() {
led_w=0xf7; di=0;
6
while(1) {
LED_crt(di); di++;
if(di>0x09) di=0; Delay(1000); } }
7
3.LCD1602⼎䆒䅵
⹀ӊ⬉䏃䆒䅵
͐1602ďϢĐēԨd⎆⼎⬉䏃GND㒓⠛U1P10P11P12P13P14P15P16P17INT1INT0C01T1T0Y1C02R1VCC4.78.2KC9VCCX1X2RSTRDWR151431191891716123456781312P10/TP11/TP12P13P14P15P16P17INT1INT0T1T0EA/VPX1X2RESETRDWRRXDTXDALE/PPSEN10113029RXDTXDALEPSENSTC12C5A60S2P00P01P02P03P04P05P06P07P20P21P22P23P24P25P26P2739383736353433322122232425262728AD0AD1AD2AD3AD4AD5AD6AD7A8A9A10A11A12A13A14A15U2A8A9E0AD0AD1AD2AD3AD4AD5AD6AD74567891011121314LCD-16021321516VCCR1310VR110kRSVSSR/WED0VoD1D2D3VDDD4D5D6BL+D7BL-GND⎆⼎(0C000H--0DFFFH)LCD1602ԅԙġ0C000H—0DFFFHēġ)0C000HĢ)0C100HĢ)ՠ0C200HĢ)ՠ0C300Hd䕃ӊ䇈ԛґġ\" 0123456789 \"; ԛґ \" ABCDEFGHIJ \"d$%&'()*+,-⏙#include \"reg51.h\" #include\"absacc.h\" typedef unsigned char BYTE; typedef unsigned int WORD; /* 1602ԙ */
#define wr_com XBYTE[0xC000] //
8
#define wr_data XBYTE[0xC100] //#define rd_com XBYTE[0xC200] //ՠ#define rd_data XBYTE[0xC300] //ՠ
void lcd_init(void); // lcdѺvoid write_cmd(BYTE cmd); // lcd
//void write_string(unsigned char *s); // ґvoid write_data(BYTE dat) ; // void set_display_place(BYTE line,column);
void write_string_lcd(BYTE line,column,unsigned char *string); //void write_data_lcd(BYTE line,column,dat); //void crti(unsigned long dat); //void crt_r(float x,BYTE N); void Delay(WORD n) {
WORD x; while(n--) {
x=500;
while(x--); } }/*
void Delay2(WORD n) {
WORD x; while(n--) {
x=5000; while(x--); } }*/
/*******************************************************************Function name: write_cmd Descriptions: lcd
******************************************************************/void write_cmd(BYTE cmd) {
BYTE dl; do {
dl=rd_com;
9
} while((dl&0x80)!=0); // wr_com= cmd; Delay(1); }
/******************************************************************Function name: write_data Descriptions:
******************************************************************/void write_data(BYTE dat) {
BYTE dl; do {
dl=rd_com; } while((dl&0x80)!=0); // wr_data= dat; Delay(1); }
/******************************************************************Function name: write_string Descriptions: ґ
******************************************************************/void write_string(BYTE *s) {
while(*s != '\\0') //'\\0'ґγ {
write_data(*s); s++; } }
/******************************************************************Function name: set_display_place Descriptions: ԅ
******************************************************************/void set_display_place(BYTE line,column) {
BYTE address; if(line == 1) {
address = 0x80 + column; }
else if(line == 2)
10
{
address = 0xc0 + column; }
write_cmd(address); }
/*****************************************************************Function name: ґӾՇԅ
Descriptions: ґlcdԅՇ
*****************************************************************/void write_string_lcd(BYTE line,column,unsigned char *string) {
set_display_place(line,column); write_string(string); Delay(1); }
/****************************************************************Function name: ӾՇԅ
Descriptions: ґlcdԅՇ
*****************************************************************//*void write_data_lcd(BYTE line,column,dat) {
set_display_place(line,column); write_data(dat); Delay(1); }*/
/***************************************************
************Ѻ**********************************************************************************/void lcd_init(void) {
write_cmd(0x38);// write_cmd(0x38);// write_cmd(0x06);// write_cmd(0x0c);// write_cmd(0x01);// }
void main() {
//SP=0x60; lcd_init();
11
因篇幅问题不能全部显示,请点此查看更多更全内容