Sketch hangs after recogniser.say

Hi there,

I am loving my new MOVI, but am having some issues with my own code. I have connected a GPS sensor to my Arduino. When I run the code, MOVI says aloud the latitude and longitude fine (code: recognizer.say("latitude is " + (String(gps.location.lat(), 3)) + "and longitude is " + (String(gps.location.lng(), 3)) + “degrees”);), but then hangs and does not print to the serial monitor which is the next line of code (code: Serial.println(“hi”);). Is it something to do with the need for a delay? Would appreciate your help! Here’s my code:


#include <TinyGPS++.h>

#include <SoftwareSerial.h>

#include “MOVIShield.h”


#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_PIC32)

#include <SoftwareSerial.h> // This is nice and flexible but only supported on AVR and PIC32 architecture, other boards need to use Serial1

#endif

MOVI recognizer(true);


static const int RXPin = 4, TXPin = 3;

static const uint32_t GPSBaud = 4800;


// The TinyGPS++ object

TinyGPSPlus gps;


// The serial connection to the GPS device

SoftwareSerial ss(RXPin, TXPin);


void setup()

{

recognizer.init();

recognizer.say(F(“Hello”));

Serial.begin(115200);

ss.begin(GPSBaud);


Serial.println(F(“GPS sensor”));

}


void loop()

{

// This sketch displays information every time a new sentence is correctly encoded.

while (ss.available() > 0)

if (gps.encode(ss.read()))

displayInfo();


if (millis() > 5000 && gps.charsProcessed() < 10)

{

Serial.println(F(“No GPS detected: check wiring.”));

while(true);

}

}


void displayInfo()

{

Serial.print(F(“Location: “));

if (gps.location.isValid())

{

Serial.print(gps.location.lat(), 6);

Serial.print(F(”,”));

Serial.print(gps.location.lng(), 6);

recognizer.say("latitude is " + (String(gps.location.lat(), 3)) + "and longitude is " + (String(gps.location.lng(), 3)) + “degrees”);

Serial.println(“hi”);

delay(5000);

}

else

{

Serial.print(F(“INVALID”));

}

Serial.println();

}



Many thanks,

Stuart

Me again,

I realised that the code line ‘signed int res=recognizer.poll();’ was missing from my sketch.

It now works.

Good that I read through the FAQs carefully :slight_smile:


Thanks,

Stuart

Sometimes it helps to just talk about it :slight_smile:


Gerald