my problem is that gsm shield uses pin 2 and pin 3 for tx and rx communication that i needed also for the hall sensor which uses also interrupt pin 3 for magnet detection, im using arduino uno board with two external interrupt pin. Is there any way that i can use same interrupt pin for different function, btw here is my code.
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"
SMSGSM sms;
char number[]="09152715557";
char message[180];
char pos;
char *p;
void setup() //declaring inputs and outputs
{
attachInterrupt(digitalPinToInterrupt(3), magnet_detect, RISING);//Initialize the intterrupt pin (Arduino digital pin 2)
half_revolutions = 0;
rpm = 0;
timeold = 0;
Serial.begin(9600);
pinMode(7, OUTPUT); //output for turning LED ON or OFF
if (gsm.begin(2400)) //condition if gsm is initialized
Serial.println("\nstatus=READY"); //displays "ready" on the serial monitor if gsm is ready
else Serial.println("\nstatus=IDLE"); //otherwise displays "idle" on the serial monitor if gsm is not found
};
void loop() //looping of the program
{
float V;
float rad;
if (half_revolutions >= 1) {
rpm = 301000/(millis() - timeold)half_revolutions;
timeold = millis();
half_revolutions = 0;
rad=rpm2((23.1416)/60);
V=(3600/1000)(0.2032rad);
Serial.print(V,DEC);
Serial.print(" kph ");
Serial.print(rpm2);
Serial.print(" rpm ");
Serial.println();
}
pos=sms.IsSMSPresent(SMS_UNREAD); //save to variable if there is an SMS
Serial.println((int)pos); //display position number (a.k.a index) of the message
if((int)pos>0&&(int)pos<=20) //if message from 0-20 is found
{
Serial.print("Message Received, INBOX="); //display an output on the serial monitor
Serial.println((int)pos); //display the position/index of the message
message[0]='\0'; //display '0' if no messages found
sms.GetSMS((int)pos,number,message,180); //get position/index, number of sender, and text message
Serial.println(message); //display the text on serial monitor
if(strstr(message, "ON"))
{
digitalWrite(7,HIGH); //if message 'ON' is received, LED is ON
}
if(strstr(message, "OFF"))
{
digitalWrite(7,LOW); //if message 'OFF' is received, LED is OFF
}
sms.DeleteSMS((int)pos); //after reading, delete SMS
}
}
void magnet_detect()//This function is called whenever a magnet/interrupt is detected by the arduino
{
half_revolutions++;
}