Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Simple sketch that will output the serial feed of GPS
- */
- #include <SoftwareSerial.h>
- const unsigned int MAX_INPUT = 150;
- const unsigned int NB_LINES = 10;
- // Software serial port.
- // only receive on pin 3
- SoftwareSerial ss(3, 2);
- void setup()
- {
- Serial.begin(115200); // serial to PC
- Serial.println("Waiting for GPS...");
- ss.begin(38400); // start serial port for the GPS
- ss.listen(); // listen on this software serial port, should not be necessary with only one software port.
- }
- void loop()
- {
- static char line[NB_LINES][MAX_INPUT];
- static unsigned int pos=0;
- static unsigned int linenb=0;
- if(ss.available()>0)
- {
- // read on hardware serial port
- //char c=Serial.read();
- // read on software serial port
- char c=ss.read();
- switch(c)
- {
- case '\n': // end of line
- line[linenb++][pos]=0; // terminate with null byte
- pos=0;
- if(linenb>=NB_LINES)
- {
- Serial.println("");
- Serial.println("Bloc");
- for(int i=0;i<NB_LINES;i++)Serial.println(line[i]);
- linenb=0;
- }
- break;
- default:
- if (pos < (MAX_INPUT - 1))
- line [linenb][pos++] = c;
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement