Sorry AWOL been re-writing from scratch and only including the essentials at moment until I establish it can work.
New code below: -
// libraries
#include <GSM.h>
#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess; // include a 'true' parameter for debug enabled
GSMVoiceCall vcs;
const int buttonPin = 4; // the number of the pushbutton pin
const int okledPin = 13; // the number of the OK LED PIN
const int failledPin = 12; // the number of the FAIL LED PIN
const int gsmfailPin = 11; // the number of the GSM LED PIN
const int callPin = 10; // the number of the CALL LED PIN
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// put your setup code here, to run once:
// initialize the LED pins as an output:
pinMode(okledPin, OUTPUT);
pinMode(failledPin, OUTPUT);
pinMode(gsmfailPin, OUTPUT);
pinMode(callPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
digitalWrite(gsmfailPin, HIGH);
delay(1000);
}
}
digitalWrite(okledPin, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
buttonState = digitalRead(buttonPin);
if (buttonPin == HIGH) {
digitalWrite(callPin, HIGH);
} else {
digitalWrite(callPin, LOW);
}
delay(50);
}
Basically I've stripped the serial monitor out of it altogether and replaced with 4 LEDs, one which illuminates when GSM is initialised, one which illuminates if GSM fails to initialise, one to illuminate when PIN 4 is High. The fourth LED is redundant at present.
Only one input which is pin 4, no physical switch, I am merely passing +5v through the pin to simulate a switch closure.
All dialling commands etc etc have been removed for the time being and so basically all I expect to happen is...
- Boot up.
- Once GSM is established then 1 x LED (Pin 13) to illuminate.
- When +5v passed through pin 4 then a further LED (Pin 11) to light up
Result is...
1 and 2 above works perfectly.
When I pass +5v through pin 4, nothing happens.
It is as if the monitoring of pin 4 or any other input for that matter does not work when the script is running.
I appreciate you may think re-writing the code from scratch is a pain but I just felt that the more I strip it back the better just to see what is going wrong.
Any help appreciated.