51单片机GPS+sim800c GSM定位短信LCD1602液晶显示 原理图+PCB+源码

目录

1、实物图

2、原理图 

​3、PCB​编辑

4、程序

资料下载地址:51单片机GPS+sim800c GSM定位短信LCD1602液晶显示 原理图+PCB+源码

1、实物图

2、原理图 

 3、PCB

4、程序

#include "common.h"
#include "uart.h"
#include "gps.h"
#include "gsm.h"


#include "lcd.h"

#define GPS_STR_LEN 48

uchar ess_inc;

//char xdata GPS_SEND_STR[GPS_STR_LEN];

sbit key = P1^3;
sbit key1 = P1^4;
sbit GPS_EN=P3^4;
sbit led1 = P3^3;
#define   RMC_YES    led1 = 0
#define   RMC_NO     led1 = 1

GPS_INFO   GPS;  //GPS信息结构体

bit GPS_rx_flag = 0;
bit GPS_Have_flag = 0;

#define SEND_NUMBER "AT+CMGS=\"13420106297\"\r\n"

char xdata send_data[37]="N:     ',E:     ',2000-00-00,00:00\r\n";
unsigned char send_len= 0;

bit dis_flag = 1;
bit sendflag=0;


/****************************************
显示时间
/****************************************/
void GPS_DispTime(void)
{
    uchar i = 0;
    uchar ch;
    char time[5];

          Int_To_Str(GPS.D.year,time);//年

    LCD1602_Set_AC(0, 1);
    i = 0;
          send_len = 18;
    while(time[i] != '\0')
    {
        ch = time[i++];

        LCD1602_write_data(ch);

                    send_data[send_len++] = ch;
    }
    LCD1602_write_data('-');
                
                Int_To_Str(GPS.D.month,time);//月
    LCD1602_Set_AC(5, 1);
    i = 0;
          send_len = 23;
    while(time[i] != '\0')
    {
        ch = time[i++];

        LCD1602_write_data(ch);

                    send_data[send_len++] = ch;
    }
    LCD1602_write_data('-');
                
                Int_To_Str(GPS.D.day,time);//日
    LCD1602_Set_AC(8, 1);
    i = 0;
          send_len = 26;
    while(time[i] != '\0')
    {
        ch = time[i++];

        LCD1602_write_data(ch);

                    send_data[send_len++] = ch;
    }
    LCD1602_write_data(',');
        
    Int_To_Str(GPS.D.hour,time);//时
    LCD1602_Set_AC(11, 1);
    i = 0;
          send_len = 29;
    while(time[i] != '\0')
    {
        ch = time[i++];

        LCD1602_write_data(ch);

                    send_data[send_len++] = ch;
    }
    LCD1602_write_data(':');

    Int_To_Str(GPS.D.minute,time);//分
    LCD1602_Set_AC(14, 1);
    i = 0;
          send_len = 32;
    while(time[i] != '\0')
    {
        ch = time[i++];

        LCD1602_write_data(ch);

                    send_data[send_len++] = ch;
    }
}


void GPS_DisplayOne(void)
{
    uchar len,ch, i;
    char info[10];

    ess_inc = 0;
//    memset(GPS_SEND_STR, 0, GPS_STR_LEN);

    if (GPS.NS == 'N')              //判断是北纬还是南纬
    {
                          if(dis_flag)
        LCD1602_DisplayChar(0, 0, 'N');
                                else
                                LCD1602_DisplayChar(0, 0, ' ');
//        GPS_SEND_STR[ess_inc ++] = 'N';
        len = 0;
        Int_To_Str(GPS.latitude_Degree,info);  //纬度

        LCD1602_Set_AC(1, 0);
        i = 0;
                    send_len = 2;
        while(info[i] != '\0')
        {
            ch = info[i++];
                                          if(dis_flag)
            LCD1602_write_data(ch);
                                                else
                                    LCD1602_write_data(' ');
                              send_data[send_len++] = ch;
//            GPS_SEND_STR[ess_inc ++] = ch;
            len ++;
        }
                    send_data[send_len++] = 'd';
                                if(dis_flag)
        LCD1602_write_data(0xDF);
                                else
                                 LCD1602_write_data(' ');
//        GPS_SEND_STR[ess_inc ++] = 'd';

        len ++;
        Int_To_Str(GPS.latitude_Cent,info);  //纬分
        i = 0;
        while(info[i] != '\0')
        {
            ch = info[i++];
                                          if(dis_flag)
            LCD1602_write_data(ch);
                                                else
                                    LCD1602_write_data(' ');
                              send_data[send_len++] = ch;
//            GPS_SEND_STR[ess_inc ++] = ch;
            len ++;
        }
                                if(dis_flag)
        LCD1602_write_data(0x27);
                                else
                                    LCD1602_write_data(' ');
//        GPS_SEND_STR[ess_inc ++] = 'm';

        Int_To_Str(GPS.latitude_Second,info);  //纬秒
        i = 0;
        while(info[i] != '\0')
        {
            ch = info[i++];
//            GPS_SEND_STR[ess_inc ++] = ch;
        }
//        GPS_SEND_STR[ess_inc ++] = 's';

        len ++;
        while(7 - len)
        {
            len ++;
            LCD1602_write_data(' ');
        }

    }

//    GPS_SEND_STR[ess_inc] = ',';
    ess_inc += 1;

    if (GPS.EW == 'E')                                //判断是东经还是西经
    {
                          if(dis_flag)
        LCD1602_DisplayChar(8, 0, 'E');
                                else
                                    LCD1602_write_data(' ');
//        GPS_SEND_STR[ess_inc ++] = 'E';

        len = 0;
        Int_To_Str(GPS.longitude_Degree,info);  //经度
        LCD1602_Set_AC(9, 0);
        i = 0;
                    send_len = 11;
        while(info[i] != '\0')
        {
            ch = info[i++];
                                          if(dis_flag)
            LCD1602_write_data(ch);
                                                else
                                    LCD1602_write_data(' ');
                              send_data[send_len++] = ch;
//            GPS_SEND_STR[ess_inc ++] = ch;
            len ++;
        }
                    send_data[send_len++] = 'd';
                                if(dis_flag)
        LCD1602_write_data(0xDF);
                                else
                                    LCD1602_write_data(' ');
//        GPS_SEND_STR[ess_inc ++] = 'd';

        len ++;

        Int_To_Str(GPS.longitude_Cent,info);  //经分
        i = 0;
        while(info[i] != '\0')
        {
            ch = info[i++];
                                          if(dis_flag)
            LCD1602_write_data(ch);
                                                else
                                    LCD1602_write_data(' ');
                              send_data[send_len++] = ch;
//            GPS_SEND_STR[ess_inc ++] = ch;
            len ++;
        }
                                if(dis_flag)
        LCD1602_write_data(0x27);
                                else
                                 LCD1602_write_data(' ');
//        GPS_SEND_STR[ess_inc ++] = 'm';

        Int_To_Str(GPS.longitude_Second,info);        //经秒
        i = 0;
        while(info[i] != '\0')
        {
            ch = info[i++];

//            GPS_SEND_STR[ess_inc ++] = ch;
        }
//        GPS_SEND_STR[ess_inc ++] = 's';

        len ++;
        while(7 - len)
        {
            len ++;
            LCD1602_write_data(' ');
        }
    }

    GPS_DispTime();

//    GPS_SEND_STR[ess_inc] = ' ';
    ess_inc += 1;

                if(sendflag==1)
                {                        
                          sendflag = 0;
                                gsm_send_englishmsg(SEND_NUMBER,send_data);//发送位置短信                                
                                delay_ms(1000);
                                delay_ms(1000);
                                LCD1602_DisplayString(0,0,"    SEND OK     "); 
                                delay_ms(1000);
                                LCD1602_DisplayString(0,0,"                "); 
                }
                
//    GPS_DispSpeed(GPS.speed, 10, 1);

//    if (GPS.D.second == 0)
//    {
//        if (GPS_Have_flag)
//        {
//            gsm_send_englishmsg(phonenum,GPS_SEND_STR);//发送位置短信
//        }
//        else
//        {
//            //gsm_send_englishmsg(phonenum,"GPS No Signal");//发送短信
//        }
//    }
}

void main(void)
{
    uchar error_num = 0;
                uint count = 0;

    GPS_EN = 0;
    GPS_rx_flag = 0;
    LCD1602_Initialize();//LCD1602显示屏初始化
    uart_init(UART_B9600);
    GPS_EN = 1;
    GPS_rx_flag = 1;
                BG = 0;
    LCD1602_DisplayString_Center(0,"GPS SCAN...");
    LCD1602_ClearLine(1);

 

  • 9
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

森旺电子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值