1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

connecting gsm with arduino and dialling number from hex kepad

Discussion in 'Arduino' started by Bob Parihar, Dec 26, 2014.

  1. Bob Parihar

    Bob Parihar Member

    Joined:
    Oct 8, 2014
    Messages:
    87
    Likes:
    0
    i want to dial a number from hex keypad to call..
    iam using interrupt method
    hex keypad uses 74c922 keypad decoder ic
    DA pin of 74c922 IC is connected to External interrupt pin 2
    whenver the button is pressed an interrupt is invoked and the corresponding 4bit number reads by MCU at pin 4,5,6 and 7

    Code (c):

    #include <LiquidCrystal.h>
    LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

    // incoming serial byte
    int number[10];  
    int a, count=0;
    void setup()
    {
      lcd.begin(16, 2);
      for(int pin=3;pin<7;pin++)
         {
         pinMode(pin, INPUT);
         }
      attachInterrupt(0, key, RISING);

       // start serial port at 9600 bps
       Serial.begin(9600);
       // wait for a while till the serial port is ready
       delay(100);
       // send the initial data once //  
      }

    void loop()
      {
       while(number[9]=='\0');    //wait till number array is full

       lcd.clear();
       for(int i=0;i<10;i++)
           {
            lcd.print(number[I]);
            }

       Serial.print("ATD");

       delay(100);
       for(int i=0;i<10;i++)
          {
          Serial.print(number);
          delay(30);
          }
       serial.print(';');

       delay(100);
       Serial.write(13);
       delay(100);

        while(1);
      }
    void key()
      {
      a=PIND&0xF0;
      a=a>>4;
      number[count++]=a;
      lcd.print(a);
      }
     
     
    Last edited by a moderator: Dec 29, 2014
  2. Bob Parihar

    Bob Parihar Member

    Joined:
    Oct 8, 2014
    Messages:
    87
    Likes:
    0
    ANYBODY? PLZZ
     
  3. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    Isn't "ATD" supposed to come BEFORE the number!!!

    Whoops!! Never mind... I was confused with the LCD print!!!
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,967
    Likes:
    1,099

    You should generally flush the serial buffer and do an "AT" and get an OK to establish that you have communication. This wasn't your original problem, just a suggestion.
     
  6. Bob Parihar

    Bob Parihar Member

    Joined:
    Oct 8, 2014
    Messages:
    87
    Likes:
    0
    problem still not solved ..
    program get stuck at the while loop at the begning after void main
     
  7. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,967
    Likes:
    1,099
    Do modify the program to just dial "AT"+Chr(13) and make sure you get an OK back. I think you should get a CR+LF combination back. There is no point in going further until you have established communication with the modem and you don't have to dial to do that.
     
  8. Bob Parihar

    Bob Parihar Member

    Joined:
    Oct 8, 2014
    Messages:
    87
    Likes:
    0
    i did once synchronized it already before doing this task... and the gsm respond OK as well..when i did made a call just by sending command using string in the program..
    but now i am doing different thing here... i am typing the number first.. storing into the array then sending it as a command..

    moreover before sending command i did print array on my lcd( as u can see in my program)..
    so at least number should get printed on lcd even the gsm synchronization is there or not doesn't matter
     
  9. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,967
    Likes:
    1,099
    Are you not printing control characters? Isn't 9, an ASCII 9 or a <ctrl>+"I"?
    In order to change digits like 0-9 into characters you have to add 48. e.f. Serial.Print(48+9) to print the ascii code for a "9"
     
  10. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    No!! The problem is "while(number[9] ==0);"

    Where is the zero coming from... If the number array was intialised with a large number and the key representing enter must be converted to the zero....

    Afterwards, KISS is correct, you need to send the ASCII value of the number...
     
  11. Bob Parihar

    Bob Parihar Member

    Joined:
    Oct 8, 2014
    Messages:
    87
    Likes:
    0
    its not '0' its '\0'
    concept is like this..
    program will be on hold till 10th byte of array occupies by some digit.. as soon as array will be full the array send as an at command to the GSM
     
  12. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    NULL , '\0', zero and 0... are all one and the same...

    Your "key" interrupt routine is just filling the number array with a binary code 1~16... there is nothing that files all the number s in the array with '\0' to start with... Ram can contain anything to start with therefore the while statement is useless... number[9] could (and often will ) have 0xFF to start off with... You need to fill the array with 0 ( zero's ) to start with.. only then will there be a zero in for the while statement to work...
     

Share This Page