Hello friends and good evening
.
I am building a back to the future style speedometer using an Arduino Uno and a GPS module Neo-6m to drive, through a MAX7219, two common cathode seven-segment displays for speed reading. The code seems to work correctly as far as the display is concerned but unfortunately there is a huge delay in the speed data output which is sometimes not even received by moving the gps module, despite having raised the output rate of the Neo-6m At 10Hz and using the NeoGPS library.
Here is the code:
digita o i#include <LedControl.h>
#include <NMEAGPS.h>
#include<AltSoftSerial.h>
AltSoftSerial gps_port;
NMEAGPS gps;
gps_fix fix;
#define DIN 12
#define CLK 11
#define CS 10
LedControl lc = LedControl(DIN, CLK, CS, 1);
const unsigned char UBLOX_INIT[] PROGMEM = {
0xB5, 0x62, 0x06, 0x08, 0x06, 0x00, 0x64, 0x00, 0x01, 0x00, 0x01, 0x00, 0x7A, 0x12, //(10Hz)
};
void setup()
{
Serial.begin( 9600 );
gps_port.begin( 9600 );
lc.shutdown(0, false);
lc.setIntensity(0, 15);
lc.clearDisplay(0);
for (unsigned int i = 0; i < sizeof(UBLOX_INIT); i++) {
gps_port.write( pgm_read_byte(UBLOX_INIT + i) );
}
}
void loop()
{
if (gps.available( gps_port )) {
fix = gps.read();
displayspeed();
}
}
void displayspeed()
{
if (fix.valid.speed) {
uint16_t knots = fix.spd.whole;
static uint16_t averageKnots = 0;
averageKnots = (averageKnots * 3) / 4 + knots;
knots = averageKnots / 4;
// Convert to other units
uint16_t mph = (knots * 1151L) / 1000L;
Serial.println(knots);
displaySpeed(mph);
}
}
void displaySpeed(float spd) {
int ispd = int(spd);
lc.clearDisplay(0);
// Split the incoming speed into digits
byte digit1 = byte((ispd / 10) % 10);
byte digit0 = byte((ispd % 10));
// Display the data and also implement Leading-Zero Blanking (LZB)
lc.setDigit(0, 0, digit0, false);
if (spd > 9.99)
lc.setDigit(0, 1, digit1, false);
}
And this is the wiring schematic:
Maybe there's some interrupt going on but i have no idea of what could cause this issue. Any answer or ideas are highly appreciated.
Thanks in advance

