找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2640|回复: 3
打印 上一主题 下一主题
收起左侧

编译错误 单片机里程和速度1602显示仿真与源码 可切换

[复制链接]
跳转到指定楼层
楼主
单片机里程和速度表仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)



51单片机里程和速度显示源程序如下:
  1. #define cystal4MHz
  2. #include <reg51.h>
  3. #include <string.h>
  4. #include "systimer.h"
  5. #include "lcd.h"
  6. #include "math.h"
  7. #include "keytask.h"
  8. uchar first_start=0;
  9. uchar timer1=0;//用于进度的显示效果
  10. uchar timer_100ms=0;
  11. uchar LCDBacklightOff_delay=11;
  12. uchar LCDBacklightOff_timer=0; 
  13. unsigned char IsSet=0;  /*设置模式标志位 0:正常走时 1:设置模式*/
  14. unsigned char SetSelect=0; /*在设置模式IsSet=1时,正在被设置的位,对应上面的宏*/
  15.    
  16.    /**************************************/
  17.    uchar time,timer_10ms;
  18.    uchar months,monthend,days=1,months=1,seconds,minutes,hours,year=10,second;
  19.    uchar menu=0,menu_flag;//界面
  20.    /**************************************/
  21.    uchar seconds_bike,minutes_bike,hours_bike;
  22.    uchar temp_work;//运动标志
  23.    uchar kilometer,kilometer_oneway;//运动千里、运动(米)
  24.    float total_distance;//总里程
  25.    unsigned long total_time;//总时间
  26.    float meter,meter_oneway;//单程距离
  27.    uchar temp_work_over;//单程结束标志
  28.    uchar timer_10ms_1=0;//运动时间计数单位
  29.    uint timer_10ms_2=0;//外部运行时间计数单位
  30.    uchar timer_work_1,timer_work;//
  31.    float speed_max=60,speed,speed_ave=0;//        最大速度、瞬时速度、平均速度
  32.    float k,l;
  33.    uchar r=26;//轮胎的半径
  34.    uchar speed_max_int, speed_max_dec ;//最大速度的整数部分和小数部分
  35.    uchar speed_int,speed_dec;                        //瞬时速度的整数部分和小数部分
  36.    uchar speed_ave_int,speed_ave_dec;        //平均速度的整数部分和小数部分
  37.    uint meter_int,meter_dec;                //里程的整数部分和小数部分
  38.    uchar meter_oneway_int,meter_oneway_dec;//里程的整数部分和小数部分
  39.    uchar timer_work_2;//外部输入标志
  40.    float work_time_t1;//外界输入时间(轮胎运行一圈的时间)
  41.    uchar temp3,temp4;
  42.    uchar NewKey1,NewKey2,NewKey3;
  43.    uchar shuru_flag;
  44.    unsigned data Temp1 = 0;   
  45.    unsigned char c = 0;
  46.    unsigned char d = 0;
  47.    unsigned a[4]; //温度数值存放
  48.    uchar code ditab[16]={0,1,1,2,3,3,4,4,5,6,6,7,8,8,9,9};
  49.    //uchar work_time_t1_int,work_time_t1_dec;//运动时间的整数部分和小数部分
  50.    /**************************************/
  51.    void Init_date(void) //日期算法
  52.    {
  53.            switch(months)
  54.            {
  55.                    case 1: monthend = 31;break;
  56.                    case 2: if(year % 4 == 0)
  57.                                    monthend = 29;
  58.                                    else monthend = 28;        break;
  59.                    case 3: monthend = 31; break;
  60.                    case 4: monthend = 30; break;
  61.                    case 5: monthend = 31; break;
  62.                    case 6: monthend = 30; break;
  63.                    case 7: monthend = 31; break;
  64.                    case 8: monthend = 31; break;
  65.                    case 9: monthend = 30; break;
  66.                    case 10: monthend = 31;break;
  67.                    case 11: monthend = 30;        break;
  68.                    case 12: monthend = 31; break;
  69.            }
  70.            if(days == monthend)
  71.            {
  72.                    days = 1;
  73.                    months++;
  74.                    if(months > 12)
  75.                    {
  76.                            months = 1;
  77.                            year++;
  78.                    }
  79.            }
  80.    }
  81.    void Init_Clock_bike(void) //时间算法
  82.    {        
  83.            if(timer_10ms_1>=100)
  84.            {
  85.                    timer_10ms_1=0;
  86.                    seconds_bike++;
  87.                    if(seconds_bike == 60)
  88.                    {
  89.                            seconds_bike = 0;
  90.                            minutes_bike++;
  91.                            if(minutes_bike ==60)
  92.                            {
  93.                                    minutes_bike=0;
  94.                                    hours_bike++;
  95.                            }
  96.                    }
  97.            }
  98.    }
  99.    
  100.    void set_date(void) //日期设置
  101.    {
  102.            switch(months)
  103.            {
  104.                    case 1: monthend = 31;break;
  105.                    case 2: if(year % 4 == 0)
  106.                                    monthend = 29;
  107.                                    else monthend = 28;break;
  108.                    case 3: monthend = 31; break;
  109.                    case 4: monthend = 30; break;
  110.                    case 5: monthend = 31; break;
  111.                    case 6: monthend = 30; break;
  112.                    case 7: monthend = 31; break;
  113.                    case 8: monthend = 31; break;
  114.                    case 9: monthend = 30; break;
  115.                    case 10: monthend = 31;        break;
  116.                    case 11: monthend = 30;        break;
  117.                    case 12: monthend = 31; break;
  118.            }
  119.            if(days == monthend+1)
  120.            {
  121.                     days = 1;
  122.            }
  123.            if(days<1)
  124.            {
  125.                    days=monthend;
  126.            }
  127.            if(months>12)
  128.            {
  129.                    months=1;
  130.            }
  131.            if(months<1)
  132.            {
  133.                    months=12;
  134.            }
  135.            if(year>99)
  136.            {
  137.                    year=0;
  138.            }
  139.            if(year<0)
  140.            {
  141.                    year=99;
  142.            }           
  143.    }
  144.    void Set_time(void) //时间设置
  145.    {
  146.            if(hours==24)
  147.            {
  148.                    hours=0;
  149.            }
  150.            if(hours<0)
  151.            {
  152.                    hours=23;
  153.            }        
  154.            if(minutes==60)
  155.            {
  156.                    minutes=0;
  157.            }
  158.            if(minutes<0)
  159.            {
  160.                     minutes=59;
  161.            }
  162.            if(seconds==60)
  163.            {
  164.                    seconds=0;
  165.            }
  166.            if(seconds<0)
  167.            {
  168.                    seconds=59;
  169.            }
  170.    }
  171.    void Init_Clock(void) //时间算法
  172.    {
  173.            if(seconds == 60)
  174.            {
  175.                    seconds = 0;
  176.                    minutes++;
  177.                    if(minutes == 60)
  178.                    {
  179.                            minutes = 0;
  180.                            hours++;
  181.                            if(hours == 24)
  182.                            {
  183.                                    hours = 0;
  184.                                    days++;
  185.                                    Init_date();//日期算法嵌套
  186.                            }
  187.                    }
  188.            }
  189.    }
  190.    void task_shuru(void)
  191.    {
  192.            if(shuru==0)
  193.            {
  194.                    shuru_flag = 1;
  195.            }
  196.    }
  197.    void display_one(void)//第一个界面
  198.    {
  199.             DisplaySinglByte(1,0,2+0x30);
  200.            DisplaySinglByte(1,1,0+0x30);
  201.            DisplaySinglByte(1,2,year/10+0x30);
  202.            DisplaySinglByte(1,3,year%10+0x30);
  203.            DisplaySinglByte(1,4,' ');
  204.            DisplaySinglByte(1,5,months / 10+0x30);
  205.            DisplaySinglByte(1,6,months % 10+0x30);
  206.            DisplaySinglByte(1,7,' ');
  207.            DisplaySinglByte(1,8,days / 10+0x30);
  208.            DisplaySinglByte(1,9,days % 10+0x30);
  209.            DisplaySinglByte(1,10,' ');        
  210.            DisplaySinglByte(1,11,hours / 10+0x30);
  211.            DisplaySinglByte(1,12,hours%10+0x30);
  212.            if(timer_10ms>=50)
  213.            {
  214.                    DisplaySinglByte(1,13,':');
  215.            }
  216.            if(timer_10ms<50)
  217.            {
  218.                    DisplaySinglByte(1,13,' ');
  219.            }
  220.            DisplaySinglByte(1,14,minutes / 10+0x30);
  221.            DisplaySinglByte(1,15,minutes % 10+0x30);
  222.    
  223.    /************************显示速度**************/
  224.            
  225.            speed_int = (int)speed;
  226.            speed_dec = (int)((speed -(float)speed_int)*100);
  227.            
  228.            if(speed_int/100>0)
  229.            {
  230.            DisplaySinglByte(2,0,speed_int/100+0x30);
  231.            }
  232.            else
  233.            {
  234.            DisplaySinglByte(2,0,' ');        
  235.            }
  236.            if(speed_int/10>0)
  237.            {
  238.            DisplaySinglByte(2,1,speed_int/10%10+0x30);
  239.            }
  240.            else
  241.            {
  242.            DisplaySinglByte(2,1,' ');        
  243.            }
  244.            DisplaySinglByte(2,2,speed_int%10+0x30);
  245.            DisplaySinglByte(2,3,'.');
  246.            DisplaySinglByte(2,4,speed_dec/10+0x30);
  247.    //        DisplaySinglByte(2,5,speed_dec%10+0x30);
  248.            DisplaySinglByte(2,5,' ');
  249.            DisplaySinglByte(2,6,a[1]+0x30);
  250.            DisplaySinglByte(2,7,a[2]+0x30);
  251.            DisplaySinglByte(2,8,'.');
  252.            DisplaySinglByte(2,9,a[3]+0x30);
  253.    /************************显示里程**************/
  254.            meter_int = (int)meter;
  255.            meter_dec = (int)((meter -(float)meter_int)*100);
  256.            //DisplaySinglByte(2,10,kilometer/100+0x30);
  257.            if(kilometer==0)
  258.            {
  259.    //                DisplaySinglByte(2,10,kilometer%100/10+0x30);
  260.                    DisplaySinglByte(2,11,kilometer%10+0x30);
  261.                    DisplaySinglByte(2,12,'.');
  262.                    DisplaySinglByte(2,13,meter_int/100+0x30);
  263.                    DisplaySinglByte(2,14,meter_int%100/10+0x30);
  264.                    DisplaySinglByte(2,15,meter_int%10+0x30);
  265.            }
  266.            if(kilometer>0)
  267.            {
  268.                    if(kilometer/100>0)
  269.                    {
  270.                    DisplaySinglByte(2,10,kilometer/100+0x30);
  271.                    }
  272.                    else
  273.                    {
  274.                            DisplaySinglByte(2,10,' ');
  275.                    }
  276.                    if(kilometer/10>0)
  277.                    {
  278.                    DisplaySinglByte(2,11,kilometer%100/10+0x30);
  279.                    }
  280.                    else
  281.                    {
  282.                            DisplaySinglByte(2,11,' ');
  283.                    }
  284.                    DisplaySinglByte(2,12,kilometer%10+0x30);
  285.                    DisplaySinglByte(2,13,'.');
  286.                    DisplaySinglByte(2,14,meter_int/100+0x30);
  287.                    DisplaySinglByte(2,15,meter_int%100/10+0x30);
  288.                    //DisplaySinglByte(2,15,meter_int%10+0x30);
  289.            }
  290.    /***********************************************/
  291.    }
  292.    void display_two()//第二个界面显示
  293.    {
  294.    /************************显示最大速度**************/
  295.            speed_max_int = (int)speed_max;
  296.            speed_max_dec = (int)((speed_max -(float)speed_max_int)*100);        
  297.            if(speed_max_int/100>0)
  298.            {
  299.                    DisplaySinglByte(1,0,speed_max_int/100+0x30);
  300.            }
  301.            else
  302.            {
  303.            DisplaySinglByte(1,0,' ');
  304.            }
  305.            if(speed_max_int%100/10>0)
  306.            {
  307.            DisplaySinglByte(1,1,speed_max_int%100/10+0x30);
  308.            }
  309.            else
  310.            {
  311.            DisplaySinglByte(1,1,' ');
  312.            }
  313.            DisplaySinglByte(1,2,speed_max_int%10+0x30);
  314.            DisplaySinglByte(1,3,'.');
  315.            DisplaySinglByte(1,4,speed_max_dec/10+0x30);
  316.            DisplaySinglByte(1,5,'k');
  317.            DisplaySinglByte(1,6,'m');
  318.            DisplaySinglByte(1,7,'/');
  319.            DisplaySinglByte(1,8,'h');
  320.            DisplaySinglByte(1,9,' ');
  321.            DisplaySinglByte(1,10,' ');
  322.            DisplaySinglByte(1,11,'R');
  323.            DisplaySinglByte(1,12,'=');
  324.            DisplaySinglByte(1,13,r/10+0x30);
  325.            DisplaySinglByte(1,14,r%10+0x30);
  326.            DisplaySinglByte(1,15,' ');
  327.            DisplaySinglByte(2,0,' ');
  328.            DisplaySinglByte(2,1,' ');
  329.            DisplaySinglByte(2,2,' ');
  330.            DisplaySinglByte(2,3,' ');
  331.            DisplaySinglByte(2,4,' ');
  332.            DisplaySinglByte(2,5,' ');
  333.            DisplaySinglByte(2,6,' ');
  334.            DisplaySinglByte(2,7,' ');
  335.            DisplaySinglByte(2,8,' ');
  336.            DisplaySinglByte(2,9,' ');
  337.            DisplaySinglByte(2,10,' ');
  338.            DisplaySinglByte(2,11,' ');
  339.            DisplaySinglByte(2,12,' ');
  340.            DisplaySinglByte(2,13,' ');
  341.            DisplaySinglByte(2,14,' ');
  342.            DisplaySinglByte(2,15,' ');
  343.    
  344.    }
  345.    /*******************************/
  346.    /**************************************/
  347.    void main(void)
  348.    {
  349.            TMOD = 0x21;
  350.            SCON = 0x50;
  351.            set_bps
  352.            //
  353.            TH0 = 0x70;
  354.            TL0 = 0x00;   
  355.            TR0 = 1;
  356.            P2 = 0xff;
  357.            //
  358.    //        WDI = ~WDI;
  359.    //                WDI = ~WDI;
  360.    //                        WDI = ~WDI;
  361.            HaveKey=0xff;
  362.            //sheld init
  363.            InitLCD();
  364.    //        LCDBacklightDelay=back_light_delay;
  365.    //        LCDBacklightOn;        
  366.    //        LCDBacklightOn;                          
  367.            //BuzzerOn;        
  368.            //BzrDelay = 5;
  369.            //打开中断
  370.            IP=0x10;  //中断优先级// PT0 = 0;        PS = 1;        
  371.            TR1 = 1;
  372.            ES         = 1;                                          
  373.             ET0 = 1;
  374.            EA         = 1;
  375.            //
  376.            while(1)
  377.            {
  378.                    //计时器
  379.                   
  380.                    WDI = 0;//便于观察
  381.                    KeyProcessTask();
  382.                    task_shuru();
  383.                    ReadTemperature();
  384.                    ChangeTemp();
  385.                    if(HaveKey==1)
  386.               {        
  387.                               if(        menu== 0)
  388.                            {
  389.                            switch (SetSelect)
  390.                             {
  391.                                      case SECOND:
  392.                                                            seconds++;
  393.                                                            if(hours==60)
  394.                                                            {
  395.                                                                     hours=0;
  396.                                                            }
  397.                                                             timer_10ms=0;
  398.                                                            HaveKey=0;
  399.                                                            break;
  400.                                    case MINUTE:
  401.                                                            minutes++;
  402.                                                            timer_10ms=0;
  403.                                                            HaveKey=0;
  404.                                                              break;
  405.                                    case HOUR:
  406.                                                            hours++;
  407.                                                            timer_10ms=0;
  408.                                                            HaveKey=0;
  409.                                                              break;
  410.                                    case DAY:  set_date();
  411.                                                            days++;
  412.                                                            timer_10ms=0;
  413.                                                            set_date();
  414.                                                            HaveKey=0;
  415.                                                              break;
  416.                                    case MONTH:
  417.                                                            months++;
  418.                                                            timer_10ms=0;
  419.                                                            HaveKey=0;
  420.                                                              break;
  421.                                    case YEAR:
  422.                                                            year++;
  423.                                                            timer_10ms=0;
  424.                                                            HaveKey=0;
  425.                                                              break;
  426.                                    }
  427.                                    }
  428.                            if(        menu== 1)
  429.                            {
  430.                            switch (IsSet)
  431.                             {
  432.                                      case MAX:
  433.                                                            if(speed_max<200)
  434.                                                            {
  435.                                                                    speed_max++;
  436.                                                            }
  437.                                                            HaveKey=0;
  438.                                                            break;
  439.                                    case R:
  440.                                                            if(r<50)
  441.                                                            {
  442.                                                                    r++;
  443.                                                            }
  444.                                                            timer_10ms=0;
  445.                                                            HaveKey=0;
  446.                                                              break;
  447.                                    }
  448.                                    }                        
  449.                               }  
  450.               if(HaveKey==2)
  451.               {        
  452.                               if(menu==0)
  453.                            {
  454.                            switch (SetSelect)
  455.                             {
  456.                                      case SECOND:
  457.                                                            seconds--;
  458.                                                            if(seconds==-1)
  459.                                                            {
  460.                                                                     seconds=59;
  461.                                                            }
  462.                                                            Set_time();
  463.                                                             timer_10ms=0;
  464.                                                            HaveKey=0;
  465.                                                            break;
  466.                                    case MINUTE:
  467.                                                            minutes--;
  468.                                                            if(minutes==-1)
  469.                                                            {
  470.                                                                     minutes=59;
  471.                                                            }
  472.                                                            Set_time();
  473.                                                            timer_10ms=0;
  474.                                                            HaveKey=0;
  475.                                                              break;
  476.                                    case HOUR:
  477.                                                            hours--;
  478.                                                            if(hours==-1)
  479.                                                            {
  480.                                                                     hours=23;
  481.                                                            }
  482.                                                            Set_time();
  483.                                                            timer_10ms=0;
  484.                                                            HaveKey=0;
  485.                                                              break;
  486.                                    case DAY:        set_date();
  487.                                                            days--;
  488.                                                            timer_10ms=0;
  489.                                                            set_date();
  490.                                                            HaveKey=0;
  491.                                                              break;
  492.                                    case MONTH:
  493.                                                            months--;
  494.                                                            timer_10ms=0;
  495.                                                            set_date();
  496.                                                            HaveKey=0;
  497.                                                              break;
  498.                                    case YEAR:
  499.                                                            year--;
  500.                                                            timer_10ms=0;
  501.                                                            set_date();
  502.                                                            HaveKey=0;
  503.                                                              break;
  504.                                    }
  505.                                    }        
  506.                                    if(        menu== 1)
  507.                                    {
  508.                                            switch (IsSet)
  509.                                     {
  510.                                              case MAX:
  511.                                                            if(speed_max>0)
  512.                                                            {
  513.                                                                    speed_max--;
  514.                                                            }
  515.                                                            HaveKey=0;
  516.                                                            break;
  517.                                            case R:
  518.                                                            if(r>0)
  519.                                                            {
  520.                                                                    r--;
  521.                                                            }
  522.                                                            timer_10ms=0;
  523.                                                            HaveKey=0;
  524.                                                              break;
  525.                                    }
  526.                                    }
  527.                               }  
  528.                                           
  529.                    if(HaveKey==3)
  530.                    {
  531.                            timer_10ms=0;
  532.                             if(menu== 1)
  533.                            {
  534.                                    if(IsSet>0)
  535.                                    {
  536.                                    IsSet--;    /*设置位的标志变量SetSelect=0:时位 1:分位 2:秒位*/
  537.                                    }
  538.                                    if(IsSet==0) /*按到第四次,即设置完秒位后,将标志位IsSet置0,完成设置*/
  539.                                     {
  540.                                      IsSet=R;
  541.                                      }
  542.                            }
  543.                             if(SetSelect>0)
  544.                                    {
  545.                                    SetSelect--;    /*设置位的标志变量SetSelect=0:时位 1:分位 2:秒位*/
  546.                            }
  547.                            if(SetSelect==0) /*按到第四次,即设置完秒位后,将标志位IsSet置0,完成设置*/
  548.                             {
  549.                                      SetSelect=YEAR;
  550.                              }
  551.                            HaveKey=0;
  552.                    }
  553.               if(HaveKey==4)//界面切换
  554.               {
  555.                            menu_flag++;
  556.                            if(menu==0)
  557.                            {
  558.                                    menu = 1;
  559.                                    HaveKey=0;
  560.                            }
  561.                            if(menu==1&&menu_flag==2)
  562.                            {
  563.                                    menu = 0;
  564.                                    menu_flag=0;
  565.                                    HaveKey=0;
  566.                            }
  567.                            
  568.               }  
  569.               if(HaveKey==5)
  570.                    {
  571.                            if(temp_work_over ==0)
  572.                            {
  573.                            temp_work=1;
  574.                            kilometer_oneway=0;
  575.                            meter_oneway = 0;
  576.                            }
  577.                            temp_work_over=1;
  578.                            HaveKey=0;                                
  579.                    }
  580.                    if(HaveKey==6)
  581.                    {
  582.                            temp_work=0;
  583.                            temp_work_over =0;
  584.                            HaveKey=0;   
  585.                    }
  586.                    if(shuru_flag==1)
  587.                    {
  588.                            if(shuru==1)
  589.                            {
  590.                            work_time_t1 = (float)timer_10ms_2*10;
  591.                            if(work_time_t1>0)
  592.                            {
  593.                            speed = 3.14*(float)r*2.54/work_time_t1*36;
  594.                            }
  595.                            timer_10ms_2 = 0;
  596.                            work_time_t1 = 0;
  597.                            timer_work_2 = 1;//计两个外部输入的时间差
  598.                            timer_work_1 = 1;//开始计运动时间
  599.                            meter = meter+3.14*2.54*r/100;
  600.                            if(temp_work==1)
  601.                            {
  602.                                    meter_oneway = meter_oneway+3.14*2.54*r/100;
  603.                            }
  604.                            shuru_flag=0;
  605.                           }
  606.                    }
  607.    
  608.                                /*第二次按C键设置分位,第三次按键设置秒位,第四次按键完成退出设置*/
  609.                    if(menu == 0)
  610.                    {        
  611.                            display_one();//显示第一个界面        
  612.                    }
  613.                    if(menu == 1)
  614.                    {        
  615.                            display_two();//显示第二个界面
  616.                    }
  617.                    if(meter >=1000)//里程进位
  618.                    {
  619.                            kilometer++;
  620.                            meter = meter -1000;
  621.                    }
  622.                   
  623.                    if(speed > speed_max)//判断是否为最大速度
  624.                    {
  625.                            alarmon;
  626.                    }
  627.                    if(speed < speed_max)//判断是否为最大速度
  628.                    {
  629.                            alarmoff;
  630.                    }
  631.                    total_distance=(float)kilometer*1000+meter;
  632.                    total_time= seconds_bike +minutes_bike*60+hours_bike*3600;
  633.                    if(total_time>0)
  634.                    {
  635.                    speed_ave = ((float)total_distance/(float)total_time)*3.6;
  636.                    }
  637.                    if(timer_10ms>=100)
  638.                    {
  639.                    seconds++;
  640.                    timer_10ms=0;
  641.                    }
  642.                    Init_Clock();
  643.                    Init_Clock_bike();
  644.                    if(timer_10ms_2 >=300)        //3秒没有第二次信号输入当超时,速度为0
  645.                    {
  646.                            timer_work_2 = 0;
  647.                            timer_work_1 = 0;
  648.                            timer_10ms_2 = 0;
  649.                            speed=0;
  650.                    }
  651.    //                WDI = 1;
  652.                    //休眠
  653.                    //休眠
  654.                    PCON|=0x01;
  655.            }
  656.    }
  657.    
  658.    /* ------------------------------------------------------------------------------
  659.    [        interrupt [0x0B] void T0_int (void)                                                                                        ]
  660.    [        comment: 定时器TO中断服务程序,定时给主循环发送20ms间隔消息                                        ]
  661.    ------------------------------------------------------------------------------ */
  662.    void T0_int (void)        interrupt 1//[0x0B]         //定时器T0 20ms 定时
  663.    {
  664.            TR0 = 0;
  665.            set_timer
  666.            TR0 = 1;
  667.            timer_10ms++;
  668.            if(timer_work_1==1)//运动时间标志
  669.            {
  670.                    timer_10ms_1++;
  671.            }
  672.            if(timer_work_2==1)//外部输入计时标志
  673.            {
  674.                    timer_10ms_2++;
  675.            }
  676.    }
  677.    //双变量延时
  678.    /*void Delay(unsigned x,unsigned y)
  679.    {
  680.        int i,j;
  681.    
  682.        for(i=0;i<x;i++)
  683.        for(j=0;j<y;j++);
  684.    }*/
  685.    
  686.    
  687.    
  688.    //温度数值的转换
  689.    void ChangeTemp()
  690.    {     
  691.            if(d==15)
  692.            {
  693.                a[0] = 10;
  694.            }
  695.            else
  696.            {
  697.                a[0] = 11;
  698.            }
  699.          
  700.            a[1] = Temp1 / 10;
  701.            a[2] = Temp1 % 10;
  702.            a[3] = ditab[c];
  703.    }
  704.    
  705.    
  706.    //显示函数
  707.    /*void DisPlay()
  708.    {      
  709.        ChangeTemp();
  710.            P1 = tab[HaveKey];
  711.            P0 = tab[dis_buff[1]];
  712.    
  713.    }*/
  714.    
  715.    //显示定时器
  716.    /*void INT_T0() interrupt 1 using 0
  717.    {        
  718.        TH0 = 0xDC;
  719.        TL0 = 0xB0;
  720.      //  ReadTemperature();
  721.        //DisPlay();
  722.    }*/
  723.    
  724.    
  725.    /*------------------------------温度传感器子程序--------------------------*/
  726.    
  727.    void Delay1(unsigned int i)
  728.    {
  729.        while(i--);
  730. ……………………

  731. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
姚伟业余爱好.zip (131.86 KB, 下载次数: 39)




评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:308395 发表于 2018-4-17 10:10 | 只看该作者
我安装的Keil4,打开编程不显示,怎么解决?
回复

使用道具 举报

板凳
ID:308395 发表于 2018-4-17 10:33 | 只看该作者
我打开编程以后,出现闪没的现象,楼主你可以将程序复制粘贴发给我吗?
回复

使用道具 举报

地板
ID:544761 发表于 2019-5-23 15:47 | 只看该作者
怎么运行不了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表