您的当前位置:首页正文

数码管

2020-09-03 来源:钮旅网
1.8Ͼ󰦥󰜝Ѡ㑻ㅵ󱰒⼎󱥻󰠊䆒䅵󰀔󰀑󰀔󰀑⹀ӊ⬉䏃䆒䅵󰀃8󰙑LED󰺡󰲵󰢶󰼪󱂔󱀎P1󰣇󰝧󱀎74HC573󰣴󱂺ԅ󰳛ѻ󰣇󰥦󱄵󰣅󱄥󰖺󰖥ē󰿷󰟑Ԩ󰦾󱀎Ӧ󰬫󰝯c8󰙑󰖟󰚛󰖝󰞉󰚕c󰺫󰦠Ԩ󱆥cTTL󰳛ѻ󰣇󰣴󱂺Ԩ󰦾ԉ󱆦юd1.1.1.P1󰦷󱥻󰠊8Ͼ󰦥󰜝Ѡ㑻ㅵ󱀈դ͙󰺬󰟜P1󰣇J12󱀰󰖟󰚛󰖝󰞉󰚕ԅ󰣅󱄥ժJ13󰺭󰥕ē󰰢󰺏󰷍󰵎󰲵dD1RP2123456789VCCD4D5D6D7D8D2D3J131234567812345678J121234567812345678P10P11P12P13P14P15P16P17LED1.1.2.74HC573󱠽󱈩ⱘ䕧󰟎󰦷󱥻󰠊8Ͼ󰦥󰜝Ѡ㑻ㅵ󱀈󰶫󰺬󰭶󰟜74HC573󰣴󱂺ԅ󰳛ѻ󰣇J14󱀰󰖟󰚛󰖝󰞉󰚕ԅ󰣅󱄥ժJ13󰺭󰥕ē󰰢󰺏󰷍󰵎󰲵d 3

󰀔󰀑󰀕󰀑䕃ӊ⿟󱑣䇈󱯢󰀃

ё󰼝󰟬󰶙󰟜0x55H(0101 0101B)󰛤0xAAH(1010 1010B)󰴢󰰦P1󰣇ē󱂕ճ󰿫󰸙0ď󰞇ԎԨ󰬼Đԅ󰿤󰟶ճ󰿫ԅ󰖟󰚛󰖝󰞉󰚕΄Ԥ󰥪d

󰀔󰀑󰀖󰀑⿟󱑣⏙󰤩󰀃

8󰙑󰖟󰚛󰖝󰞉󰚕󰺡󰲵󰼪󱂔󱀎P1󰣇󰣅󱄥ēё󰼝󰰢󰺏ġ#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󰳴󰧲󰚕󰳴󰡬󰺡󰲵ԅ󰿷󰟑Ԩ󰦾󱀎Ӧ󰬫󰝯c4󰸪󰙫󰽽󰝾󰳴󰧲󰚕c󰸪󰯚ՎԨ󰦾c󰺫D

󰦠Ԩ󱆥ԉ󱆦юd󰲬󰽲͐󱄯󰟜󰶫󰺬J7󱀰J2ďA8—A11󰟶Đ󰺭󰥕ē󰞇Ӧ󰬫󰝯P2.0-P2.3󰣅󱄥󰳴󰧲󰚕4󰸪󰸪󰼪d󱀈󰶫󰺬󰟜J14󱀰J15󰺭󰥕ē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

因篇幅问题不能全部显示,请点此查看更多更全内容