+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Newbie level 2
    Points: 171, Level: 2

    Join Date
    Jan 2012
    Posts
    2
    Helped
    0 / 0
    Points
    171
    Level
    2

    check my code it is not working "GSM based moving display"

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    
    #include<reg51.h>
    #include<string.h>
    #include "lcd.h"
    sbit rs=P3^7; 
    sbit rw=P3^6;
    sbit en=P3^5;
    void lcdcmd(unsigned char value);
    void lcddata(unsigned char value);
    void lcdstr(unsigned char *);
    void delay_lcd();
    void delay_100milli(unsigned char d);
    void init();                            
    void serialinit();
    void serial_init();
    void Tx_Data(unsigned char);
    unsigned char Rx_Data(void);
    void SCI_String_Tx(unsigned char *string);
    void Enter_cmd(void);
    int i;
    unsigned char number[10];
    unsigned char mes1[21], mes2[21], mes3[21], mes4[21], *num="9964709968";
    void main()
    {
     delay_100milli(50);
     serialinit();
     
     SCI_String_Tx("AT+CMGF=1");
     Enter_cmd();                
     while(Rx_Data()!='k');
     init();
     lcdcmd(0x80);
     delay_lcd();
     lcdstr("MSRIT");
     lcdcmd(0xc0);
     delay_lcd();
     lcdstr("Bangalore");
     lcdcmd(0xD4);
     delay_lcd();
     lcdstr("GSM BASED NOTICE BOARD");
     lcdcmd(0x94);
     delay_lcd();
     lcdstr("DEPT OF ECE 2009-2013");
     while(1)
     { 
      for(i=0;i<13;i++)
          Rx_Data();
      for(i=0;i<10;i++)
      number[i]=Rx_Data();
      if(!strncmp(num,number,9))      
      {                              
      for(i=0;i<27;i++)
          Rx_Data();
      for(i=0;i<20;i++)
      mes1[i]=Rx_Data();
      mes1[21]='\0';
      for(i=0;i<20;i++);
      mes2[i]=Rx_Data();
      mes2[21]='\0';
      for(i=0;i<20;i++)
      mes3[i]=Rx_Data();
      mes3[21]='\0';
      for(i=0;i<20;i++);
      mes4[i]=Rx_Data();
      mes4[21]='\0';
      }
     
      lcdcmd(0x80);
      delay_lcd();
      lcdstr("MESSAGE RECIEVED FROM");
      lcdcmd(0xc0);
      delay_lcd();
      lcdstr(&number);
      lcdcmd(0xca);
      delay_lcd();
      lcdstr("                ");
      lcdcmd(0x94);
      delay_lcd();
      lcdstr("                ");
      lcdcmd(0xD4);
      delay_lcd();
      lcdstr("                ");
      delay_100milli(50);
      if(!strncmp(num,number,9))
      {
       lcdcmd(0x80);
       delay_lcd();
       lcdstr(&mes1);
       lcdcmd(0xC0);
       delay_lcd();
       lcdstr(&mes2);
        lcdcmd(0x94);
        delay_lcd();
       lcdstr(&mes3);
        lcdcmd(0xD4);
        delay_lcd();
        
       lcdstr(&mes4);
       }
       else
      {
       lcdcmd(0x94);
       lcdstr("SNT BY UNAUTRSD USER");
       lcdcmd(0xd4);
       lcdstr("NT PERMITED T DISPLY");
       delay_100milli(80);
       lcdcmd(0x80);
       lcdstr(&mes1);
       lcdcmd(0xC0);
       lcdstr(&mes2);
        lcdcmd(0x94);
       lcdstr(&mes3);
        lcdcmd(0xD4);
       lcdstr(&mes4);
       }
    }
    }
     
     
    void serialinit()
    { 
      TMOD=0x20;
      SCON=0x50;
      TH1=-3;
      TR1=1;
      TI=0;
    }
     
     
    void Tx_data(unsigned char v)
    {
      SBUF=v;
      while(TI==0);
      TI=0;
    }
     
    unsigned char Rx_Data(void)
    {
      unsigned char in;
      while(!RI);
      in=SBUF;
      RI=0;
      return(in);
    }
     
     
    void SCI_String_Tx(unsigned char *string)
    { 
      while(*string)
      { 
       Tx_data(*(string++));
      }
    }
     
     
     
    void Enter_cmd(void)
    {
       Tx_data(0x0D);
       Tx_Data(0x0A);
    }
     
     
    void init()
    {
     lcdcmd(0x38);
     delay_lcd();
     lcdcmd(0x0C);
     delay_lcd();
     lcdcmd(0x01);
     delay_lcd();
     lcdcmd(0x06);
     delay_lcd();
     lcdcmd(0x80);
     delay_lcd();
    }
     
     
    void lcdcmd(unsigned char value)
    {
    P1=value;
    rs=0;
    rw=0;
    en=1;
    delay_lcd();
    en=0;
    }
     
     
     
    void lcddata(unsigned char value)
    {
      P1=value;
      rs=1;
      rw=0;
      en=1;
      delay_lcd();
      en=0;
    }
     
     
     
    void delay_lcd()
    {
      int i,j;
      for(i=0;i<10;i++)
      for(j=0;j<150;j++);
      }
     
     
    void lcdstr(unsigned char *ptr)
    {
       while(*ptr!='\0')
       lcddata(*ptr++);
    }
     
     
    void delay_100milli(unsigned char d)
    {
       int i,j;
       for(i=0;i<d;i++)
       for(j=0;j<18000;j++);
    }
    Last edited by alexan_e; 1st May 2012 at 08:55. Reason: added SYNTAX tags

    •   AltAdvertisment

        
       

  2. #2
    Advanced Member level 3
    Points: 5,481, Level: 17

    Join Date
    Apr 2011
    Posts
    926
    Helped
    184 / 184
    Points
    5,481
    Level
    17

    Re: check my code it is not working "GSM based moving display"

    check my code it is not working "GSM based moving display"
    which part is not working do you able to receive msg from gsm device or module??
    please specify your exact problem.



    •   AltAdvertisment

        
       

  3. #3
    Junior Member level 2
    Points: 866, Level: 6

    Join Date
    Apr 2012
    Posts
    20
    Helped
    0 / 0
    Points
    866
    Level
    6

    Re: check my code it is not working "GSM based moving display"

    explain the problems, which will help us more accurate to solve



    •   AltAdvertisment

        
       

  4. #4
    Banned
    Points: 3,760, Level: 14
    Achievements:
    7 years registered

    Join Date
    Feb 2010
    Location
    Muscat, Oman, Oman
    Posts
    388
    Helped
    64 / 64
    Points
    3,760
    Level
    14

    Re: check my code it is not working "GSM based moving display"

    how u came to know the code isnt working? is it that its not compiling or is it giving errors, or u are not getting the results u want from the code.

    No one has enough free time to go around ur complete code and find the problems like that !! so details of the problem plz



--[[ ]]--