Continue to Site

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.

  • 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.

connecting gsm with arduino and dialling number from hex kepad

Status
Not open for further replies.
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

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:
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.
 
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.
 
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.

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
 
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"
 
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...
 
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...

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
 
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...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top