Thanks for anyone's help on this in advance. My goal is to combine a GPS receiver (NEO-6M), and a Nano or Pro mini to convert the lat and longitude numbers coming out of the TinyGPS library to the Morse Code equivalent which would key an output pin with the Morse Code characters. I have two separate programs now working that do the tasks individually: Program 1) Receive data from the GPS module and display lat/long from the TinyGPS library on the serial monitor screen , and Program 2) Take a hardcoded character (letter or number or message) and convert to a Morse character and key an output pin.
What I can't figure out is how to now combine both programs so the Morse generator program receives the lat/long numbers from the GPS program and ultimately keys the output pin with the lat/long numbers in Morse.
Seems like I need to convert the lat/long numbers to a serial stream of characters that the Morse program will accept one at time.
The TinyGPS library outputs two items, one called gps.location.lat and the other is gps.location.long. I am not sure if these are characters or actual numbers like a float.
I would then think I would need to create maybe a string that has the numbers in the correct serial sequence to be fed as characters to the Morse program one at time. This is where I get totally lost on what to do.
So I guess my question would be: How do you convert the TinyGPS output to a serial stream of characters, not actual numbers, that the Morse program would accept.
Here is the program that processes the GPS data:
/*
* Rui Santos
* Complete Project Details http://randomnerdtutorials.com
*/
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
void setup(){
Serial.begin(9600);
ss.begin(GPSBaud);
}
void loop(){
// This sketch displays information every time a new sentence is correctly encoded.
while (ss.available() > 0){
gps.encode(ss.read());
if (gps.location.isUpdated()){
Serial.print("Latitude= ");
Serial.print(gps.location.lat(), 6);
Serial.print(" Longitude= ");
Serial.println(gps.location.lng(), 6);
}
}
}
Here is the program that processes the Morse code characters:
//
// Simple Arduino Morse Beacon
// Written by Mark VandeWettering K6HX
// Email: k6hx@arrl.net
//
// This code is so trivial that I'm releasing it completely without
// restrictions. If you find it useful, it would be nice if you dropped
// me an email, maybe plugged my blog @ https://brainwagon.org or included
// a brief acknowledgement in whatever derivative you create, but that's
// just a courtesy. Feel free to do whatever.
//
struct t_mtab { char c, pat; } ;
struct t_mtab morsetab[] = {
{'.', 106},
{',', 115},
{'?', 76},
{'/', 41},
{'A', 6},
{'B', 17},
{'C', 21},
{'D', 9},
{'E', 2},
{'F', 20},
{'G', 11},
{'H', 16},
{'I', 4},
{'J', 30},
{'K', 13},
{'L', 18},
{'M', 7},
{'N', 5},
{'O', 15},
{'P', 22},
{'Q', 27},
{'R', 10},
{'S', 8},
{'T', 3},
{'U', 12},
{'V', 24},
{'W', 14},
{'X', 25},
{'Y', 29},
{'Z', 19},
{'1', 62},
{'2', 60},
{'3', 56},
{'4', 48},
{'5', 32},
{'6', 33},
{'7', 35},
{'8', 39},
{'9', 47},
{'0', 63}
} ;
#define N_MORSE (sizeof(morsetab)/sizeof(morsetab[0]))
#define SPEED (20)
#define DOTLEN (1200/SPEED)
#define DASHLEN (3*(1200/SPEED))
int LEDpin = 13 ;
void dash()
{
digitalWrite(LEDpin, HIGH) ;
delay(DASHLEN);
digitalWrite(LEDpin, LOW) ;
delay(DOTLEN) ;
}
void dit()
{
digitalWrite(LEDpin, HIGH) ;
delay(DOTLEN);
digitalWrite(LEDpin, LOW) ;
delay(DOTLEN);
}
void
send(char c)
{
int i ;
if (c == ' ') {
Serial.print(c) ;
delay(7*DOTLEN) ;
return ;
}
for (i=0; i<N_MORSE; i++) {
if (morsetab[i].c == c) {
unsigned char p = morsetab[i].pat ;
Serial.print(morsetab[i].c) ;
while (p != 1) {
if (p & 1)
dash() ;
else
dit() ;
p = p / 2 ;
}
delay(2*DOTLEN) ;
return ;
}
}
/* if we drop off the end, then we send a space */
Serial.print("?") ;
}
void
sendmsg(char *str)
{
while (*str)
send(*str++) ;
Serial.println("");
}
void setup(){
pinMode(LEDpin, OUTPUT);
Serial.begin(9600);
Serial.println("Simple Arduino Morse Beacon v0.0");
Serial.println("Written by Mark VandeWettering <k6hx@arrl.net>");
Serial.println("Check out my blog @ https://brainwagon.org");
Serial.println("");
}
void loop() {
sendmsg("THIS IS A TEST MORSE MESSAGE") ;
delay(3000) ;
}
Thanks again for any help.