»ùÓÚ51µ¥Æ¬»úµÄÈý²ãµçÌÝϵͳÉè¼Æ - ͼÎÄ ÏÂÔر¾ÎÄ

»ùÓÚµ¥Æ¬»úµÄÈý²ãµçÌÝϵͳÉè¼Æ

¸½Â¼1 Ôª¼þÇåµ¥

ÐòºÅ Ãû³Æ ÐͺŠµ¥Î» ÊýÁ¿ ±¸×¢ 1 2 3 4 5 µç×è µçÈÝ ¾§Õñ °´¼ü 7¶ÎÏÔʾÊýÂë¹Ü 10K 30P 12MHZ --- SM42038 Ö§ Ö§ Ö§ ¸ö ¸ö 1 3 1 8 2 6 7 8 9 10 11 12 µç³ØºÐ µç³Ø µ¼Ïß¼°º¸Îý ×ÔËø¿ª¹Ø ÅÅ×è µ¥Æ¬»ú ÍòÓðå --- --- --- --- 102 AT89C51 --- ¸ö ½Ú --- ¸ö ¸ö ¸ö ¿é 1 3 Èô¸É 1 2 1 1

1

»ùÓÚµ¥Æ¬»úµÄÈý²ãµçÌÝϵͳÉè¼Æ

¸½Â¼2 ³ÌÐò²¿·Ö

#include #define LCD1 P1 #define LCD2 P3

void Zero();

void Delay_ms(unsigned int Time);

void Display(unsigned int n,unsigned char a); void Flash(unsigned int Time); void KBScan(); void dl_ms(); void Destination(); void Up(); void Down();

//P2Óë²éѯʽ¼üÅÌÓ²¼þÏàÁ¬ sbit P2_0=P2^0; sbit P2_1=P2^1; sbit P2_2=P2^2; sbit P2_3=P2^3; sbit P2_4=P2^4; sbit P2_5=P2^5; sbit P2_6=P2^6;

unsigned int lift=1; /*µçÌÝËùÔÚÂ¥²ã*/

unsigned int status=1; /*µçÌÝÉÏÐÐΪ1£¬ÏÂÐÐΪ0*/ unsigned char request[3]={0,0,0}; /*1~3Â¥ÓÐÎÞÇëÇó£¬ÓÐÇëÇóΪ1*/ unsigned char dst=1; /*µçÌݵÄÄ¿µÄÂ¥²ã*/

//ÇåÁã³ÌÐò void Zero() {

LCD1=0x00; LCD2=0x00; }

//ÑÓʱ³ÌÐò£¬ÒÔºÁÃëΪµ¥Î»£¬ÓÃÈí¼þ¼Æʱ£¬ÊäÈëµÄ²ÎÊý void Delay_ms(unsigned int Time) {

unsigned int i=0,j=0;

2

»ùÓÚµ¥Æ¬»úµÄÈý²ãµçÌÝϵͳÉè¼Æ

for(i=0;i

KBScan(); for(j=0;j<125;++j); } }

//ÏÔʾijһ¥²ã

void Display(unsigned int n,unsigned char a) {

unsigned char b; if(a==0) { b=0x5e; }

else if(a==1) { b=0x73; } Zero(); KBScan(); LCD2=b; KBScan(); switch(n) {

case 3:{LCD1=0x4f;break;} case 2:{LCD1=0x5b;break;} case 1:{LCD1=0x06;break;} default: {break;} } }

//ÉÁ˸ÏÔʾµ½´ïÂ¥²ã void Flash(unsigned int Time) {

unsigned char i; for(i=0;i

Delay_ms(1000); KBScan(); Display(lift,status);

3

»ùÓÚµ¥Æ¬»úµÄÈý²ãµçÌÝϵͳÉè¼Æ

Delay_ms(1000); KBScan(); } Zero();

Delay_ms(1000); KBScan(); }

//²éѯʽ¼üÅÌɨÃè void KBScan() {

if(P2!=0xff) { dl_ms(); if(P2!=0xff) {

switch(P2) {

case 0xfe: {P0_0=1;request[0]=1;break;} /*µçÌÝÄÚÇëÇó1Â¥*/

case 0xfd: {P0_1=1;request[1]=1;break;} /*µçÌÝÄÚÇëÇó2Â¥*/ case 0xfb: {P0_2=1;request[2]=1;break;} /*µçÌÝÄÚÇëÇó3Â¥*/ case 0xf7: {P0_3=1;request[0]=1;break;} /*µçÌÝÍâ1Â¥ÇëÇóÏòÉÏ*/ case 0xef: {P0_4=1;request[1]=1;break;} /*µçÌÝÍâ2Â¥ÇëÇóÏòÉÏ*/ case 0xdf: {P0_5=1;request[1]=1;break;} /*µçÌÝÍâ2Â¥ÇëÇóÏòÏÂ*/ case 0xbf: {P0_6=1;request[2]=1;break;} /*µçÌÝÄÚ3Â¥ÇëÇóÏòÏÂ*/

default: {break;} /*´íÎóÇëÇó*/ } } } }

//Ïû¶¶ÑÓʱ void dl_ms() {

unsigned char i; for(i=0;i<30;++i); }

//»ñÈ¡Ä¿µÄÂ¥²ã void Destination() {

unsigned char j; //jÑ­»·¿ØÖƱäÁ¿ KBScan(); //Óмü°´ÏÂ

4