Maybe here:
~~ x=Serial.read();~~
~~ //Serial.println(y);~~
~~ if(x==49)~~
Look at parseint()
Edit:
The above is OK. It looks like you are getting the ASCII values of 0,1&2 in your code, not an arbitrary integer as I originally thought.
-
It is not clear what is on pin 7 and it looks like you have half commented out the pinMode() statement for it. I guess LOW enables the GPS device but it may require time to lock back on before it is readable.
-
I'm not sure how Software Serial reacts to multiple begin() calls without a matching end() call. Why do you do this on each function call and not simply once in setup() :
serialgps.begin(9600);//Iniciamos el puerto serie del gps
-
Maybe you should post a wiring diagram to make things clearer.
-
Maybe try setting this to false:
#define USE_ARDUINO_INTERRUPTS true // Set-up low-level interrupts for most acurate BPM math.