Hi there!
I have tried this simple thing for some time now and can't get it to work. I will use my matrix keyPad to dial the phone number I want to call. I started to feel that I have tried everything. I use some Norwegian words and shortcuts so just try to understand me
, but here is my code:
////Libs//////////////////////////////////
#include <Key.h>
#include <Keypad.h>
#include <SoftwareSerial.h>
//////////////////////////////////////////
///SoftwareSerial/////////////////////////
SoftwareSerial sim900(2, 3);
//////////////////////////////////////////
////char//////////////////////////////////
char telNR[] = {"00000000"};
char key;
//////////////////////////////////////////
////INTes/////////////////////////////////
int antT = 0;
//////////////////////////////////////////
////Tast opsett - keyPad//////////////////
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
 {'1', '2', '3', 'A'},
 {'4', '5', '6', 'B'},
 {'7', '8', '9', 'C'},
 {'*', '0', '#', 'D'}
};
/////////////////////////////////////////
////Pin oppsett///////////////////////////
byte rowPins[ROWS] = {3, 4, 5, 8};
byte colPins[COLS] = {9, 10, 11, 12};
//////////////////////////////////////////
////Oppsett keyPad////////////////////////
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
//////////////////////////////////////////
void setup() {
 // put your setup code here, to run once:
 Serial.begin(9600);
 sim900.begin(9600);
}
void loop() {
 // put your main code here, to run repeatedly:
 key = keypad.getKey();
 if (key) {
  if (key >= '0' && key <= '9' && antT < 8) {
   telNR[antT] = key;
   antT++;
  }
 }
 if (antT >= 8) {
   sim900.print("ATD");
   sim900.print(telNR);
   sim900.println(";");
   Serial.println("Ringer....");
   Serial.print(telNR);
   reset();
  }
}
void reset() {
 telNR[0] = 0;
 telNR[1] = 0;
 telNR[2] = 0;
 telNR[3] = 0;
 telNR[4] = 0;
 telNR[5] = 0;
 telNR[6] = 0;
 telNR[7] = 0;
 antT = 0;
}
It serial print "Ringer.....(telNR)" "Ringer" is Norwegian for calling btw
, but does not serial print the AT command to the sim900.
But when I but
sim900.print("ATD");
   sim900.print(telNR);
   sim900.println(";");
in void setup() and change "char telNR" to my phone number it works.
So why does it work under void setup() and not under "if (antT >= 8 )", and under there it does serial print to the serial monitor but not to the sim900, and in the serial monitor it prints the right number to call, so that's should mean that the sim900 is getting the right number.
Please help me, I'm thoughtless.
Thanks! ![]()