Hello all! I am new to Arduino and am having trouble with my first project. It may be too ambitious, but I'm building this speedometer for a specific project. I followed a "how to" and bought all the hardware listed in the "Instructable."
I having trouble getting my GPS Speedometer to display a speed. The sketch boots up on the nano, but I do not get a speed output, nor any of the errors coded in to the sketch. The screen is also very "glitchy," it cuts in and out. Sometimes it doesn't come on at all when I boot the nano. I'm guessing this could be a memory issue?
Any help is greatly appreciated.
Pinout diagram attached.
Hardware: Arduino Nano, SH1106 OLED, and NEO-6M GPS
Code:
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <Adafruit_SH1106.h>
#define OLED_ADDRESS 0x3C
#define OLED_RESET -1
Adafruit_SH1106 display(OLED_RESET);
int RXin = 2, TXin = 3;
TinyGPSPlus gps;
SoftwareSerial ss(RXin, TXin);
void setup()
{
Serial.begin(9600);
ss.begin(9600);
display.begin(SH1106_SWITCHCAPVCC, OLED_ADDRESS);
display.clearDisplay();
display.display();
}
void loop()
{
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(27, 2);
display.print("CIRCUIT DIGEST");
display.setTextSize(1);
display.setCursor(35, 20);
display.print("SPEED(KMPH)");
display.display();
while (ss.available() > 0)
if (gps.encode(ss.read()))
displayspeed();
if (millis() > 5000 && gps.charsProcessed() < 10)
{
display.setTextSize(1);
display.setCursor(35, 40);
display.print("Error!!!");
display.display();
while (true);
}
}
void displayspeed()
{
if (gps.speed.isValid())
{
display.setTextSize(2);
display.setCursor(40, 40);
display.print(gps.speed.mph());
display.display();
}
else
{
display.setTextSize(1);
display.setCursor(35, 40);
display.print("No Data!!!");
display.display();
}
delay(100);
}