GSM Shield and Pin 2

Hello.It is possible to use the GSM Shield Tx pin as interrupt like Pin 2(Digital pin) on Arduino uno?.
Thank you.

Hello.I am working in a project with GSM Shield - Arduino Uno R3 and a sensor which send voltage pulses to Arduino board.
The next step is to join the GSM Shield to Arduino to send data to webserver but GSM hasn't interrupts pins(attachInterupt()) and i would like to use A0 as pulses in.My question is if there is a command or funtion to measure the change HIGH to LOW like
attachInterrupt(0 or 1, function to call, FALLING) on digital pins.

Thank you very much

Why do you need interrupts? Read the pin on every pass through loop(), to discover when it changes. If "on every pass through loop()" isn't often enough, rewrite your code so that it is.

It is possible to use the GSM Shield Tx pin as interrupt like Pin 2(Digital pin) on Arduino uno?.

Sure. As long as you don't need to be able to transmit.

Hi.So it is possible that rewriting the code the behavior between attachInterrupt() function and loop() options be the same?.The only step to complete the project is to count only when pass HIGH to LOW to obviate that an object permanently be detected by the sensor.

Hi.I believed that GSM TX only supports transmissions.I will connect a voltage pulse to pin 2.

Thank you.

So it is possible that rewriting the code the behavior between attachInterrupt() function and loop() options be the same?

I don't understand the question.

The interrupt service routine that attachInterrupt() resisters and what the loop() function was doing may be the same thing.

The attachInterrupt() function and the loop() function will never have the same behavior.

The only step to complete the project is to count only when pass HIGH to LOW to obviate that an object permanently be detected by the sensor.

What objects are passing by what sensors at what speeds? Unless the speed of the objects is high, and the objects are small, there is no need to use interrupts.

What's the point of having a GSM shield if you aren't sending anything?

You might want to look into pin change interrupts.

Sorry.The object of the project is to count people with photoelectric sensor and send data using a GSM Shield so attachInterrupt() function is the best option i have found.I I had thought in alternatives to that function and use analog pin to count and store data in a variable.
Thanks

The object of the project is to count people with photoelectric sensor and send data using a GSM Shield

In your other thread, you said you wouldn't be sending.

People move slowly. Do NOT use interrupts to count people.

I have done the connection voltage input on GSM TX pin of GSM Shield.The monitor ouput is a randomly values.Must i configurate the GSM TX pin to digital Pin 2 before?

ok i will rewrite the code to count using A0 for example.You have clarified me several doubts .I will keep you informed.

Thank you very much

patricio_74:
and i would like to use A0 as pulses in.My question is if there is a command or funtion to measure the change HIGH to LOW like
attachInterrupt(0 or 1, function to call, FALLING) on digital pins.

You can monitor change on pins. You target one or more pins and when the status of any of this pins changes, it will trigger an interrupt. In your routine you should (quickly) check the current status of the monitored pins. If you are monitoring more than one, you need to quickly check which of them triggered ths interrupt. You can monitor RISING, FALLING and CHANGE status.

An example:

#include <PinChangeInt.h>
#define DATA 8

void setup() {
  pinMode(DATA, INPUT);
  PCintPort::attachInterrupt(DATA, &cambio, CHANGE);
}

void cambio() {
if (digitalRead(DATA)==HIGH){  //this is a rising edge
    ........ code .......
      }    
else { //this is a falling edge
    ...... code.....
    }
}

Here is a project where I used this method: Programacion, electronica, Linux y un poco de todo: Hackeando termómetro inalámbrico (google translated)
I'm attaching the library I used just in case.

PinChangeInt.zip (43.1 KB)

If the program is doing nothing but loop round waiting for the state of an input pin to change from HIGH to LOW then there is nothing to interrupt, so why complicate things by using an interrupt of any kind ?

Hello.Thanks for all your information.I have used the code and it's works.The only changes i have done is CHANGE to FALLING and in cambio() function,i have declared a variable 'cont' wich up every calls:

#include <PinChangeInt.h>
#define DATA 8
int cont=0;
void setup() {
  pinMode(DATA, INPUT);
  PCintPort::attachInterrupt(DATA, &cambio, FALLING);
}

void cambio() {
cont++;
}

Just in case size matters:

#include <PinChangeInt.h>
#define DATA 8
int cont=0;

void setup() 
{
  pinMode(DATA, INPUT);
  PCintPort::attachInterrupt(DATA, &cambio, FALLING);
}

void cambio() 
{
cont++;
}

void loop()
{
}

Binary sketch size: 2,386 bytes (of a 32,256 byte maximum)

const byte DATA = 8;
int cont = 0;

void setup() 
{
}

void loop() 
{
  static byte prevState = HIGH;
  static byte curState = HIGH;
  curState = digitalRead(DATA);
  if (curState == LOW && prevState == HIGH)
  {
    cont++;
  }
  prevState = curState;
}

Binary sketch size: 770 bytes (of a 32,256 byte maximum)

Thank you very much.It's works.