标题: 蓝牙模块怎么读取单片机数码管上的数字 [打印本页]

作者: szxyp    时间: 2017-12-25 14:52
标题: 蓝牙模块怎么读取单片机数码管上的数字
把单片机数码管上的数字通过蓝牙模块读取出来发送给手机
下面是单片机数码管显示的程序,怎么加上蓝牙模块
#include "reg52.h"                         
#include<intrins.h>               

typedef unsigned int u16;         
typedef unsigned char u8;

sbit beep=P1^5;         
sbit a=P2^0 ;       
sbit LSA=P2^2;       
sbit LSB=P2^3;
sbit LSC=P2^4;
u8 code smgduan[10]={
        0x3f,   //0
        0x06,          //1
        0x5b,        //2
        0x4f,        //3
        0x66,        //4
        0x6d,          //5
        0x7d,        //6
        0x07,        //7
        0x7f,        //8
        0x6f,        //9
        };          

void delay(u16 i)
{
        while(i--);                  //Ñóê±oˉêy£¬i=1ê±£¬′óÔ¼Ñóê±10us
}



void main()
{       
   u16 L0=0,L1=0,L2=0,L3=0,d,n=0,w=0;
       
        TMOD|=0X01;                //  01¶¨ê±  04¼Æêy  Ñ¡ÔñÎa¶¨ê±Æ÷0ģ꽣¬1¤×÷·½ê½1£¬½öóÃTR0′ò¿aÆô¶ˉ¡£

        TH0=0X3C;                //¸ø¶¨ê±Æ÷¸33õÖ죬¶¨ê±1ms   
        TL0=0XB0;                                                    
       
        TR0=1;                        //′ò¿a¶¨ê±Æ÷

         if(w==0)
        {       
                delay(100);
                if(a==1)
                {
              L0++;
                 while(1)
       {
           if(L0==10)
                {
                        L0=0;
                        L1++;
                }
                if(L1==10)                                                          
                {
                        L1=0;
                        L2++;
                }
                if(L2==10)
                {
                        L2=0;
                        L3++;
                }
                if(L3==10)
                {
                    L3=0;
                        L0=0;L1=0;L2=0;
                }
                if(L2==9)
                {
                     beep = 1;
                }


                for(d=0;d<4;d++)
                {
                        switch(d)         
                        {
                                case(0):
                                        LSA=0;LSB=0;LSC=0;P0=smgduan[L0]; break;//ÏÔê¾μú0λ
                                case(1):
                                        LSA=1;LSB=0;LSC=0;P0=smgduan[L1]; break;//ÏÔê¾μú1λ
                                case(2):
                                        LSA=0;LSB=1;LSC=0;P0=smgduan[L2]; break;//ÏÔê¾μú2λ
                                case(3):
                                        LSA=1;LSB=1;LSC=0;P0=smgduan[L3]; break;//ÏÔê¾μú3λ
                        }
                        delay(100);
                        P0=0x00;           //Ïûòt
                }
                if(a==1)
                delay(10000);                                                                       
                L0++;
       
       
                if(TF0==1)
        {
            TF0=0;       
                TH0=0X3C;              //ÖØÖö¨ê±3£êy
                TL0=0XB0;
                n++;
                if(n>200)
                {
                  n=0;
                  w=1;
                }
                if(w==1)
                a=0;
    }
               
        }
        }               
        }
                }  

                       



作者: aking991    时间: 2018-6-29 22:50
既然能让显示,就把显示的数据也通过串口蓝牙发送出去不就得了吗
作者: botgs    时间: 2018-6-30 11:24
不太明白,就把你的L0,L1,L2,L3用蓝牙串口发出去不就行了嘛。




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1