LED GPS Speedometer having issues

I’m trying to make a speedometer that will change colors depending on the speed on which I am traveling.

If the speed is decreasing at any time or below 5 mph LEDs be red.

And if the speed is above 5 mph or increasing speed the LEDs will be a different color.

I am using an Adafruit 24 NeoPixel ring for LED’s and a u-blox NEO-6 GPS module.

And the GPS is sometimes not registering the speed or any other GPS values and not switching colors when speed is at certain values or when it is increasing or decreasing. It tends to stay only one color no matter the speed. Also the GPS is not registering speeds above zero when I ride my bike or in a moving car.

I added a picture of the values I am getting, it seems to be connecting to satellites and getting correct GPS coordinates but as soon as I as I take it to real world test, the speed inst changing and LEDs are not changing. I also included a picture of the Arduino configuration I am using.

I am a very new to coding so any help would be very grateful.

(if anyone could help with the accelerating and decelerating code to that would be absolutely amazing!!!)

#include "TinyGPS++.h"
#include "SoftwareSerial.h"
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define LED_PIN  6
#define LED_COUNT 24
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_RGB + NEO_KHZ800);
SoftwareSerial serial_connection(10,11);
TinyGPSPlus gps;
int val = 0;
int prev;
void setup() {
  #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif
  strip.begin();
  strip.show();
  strip.begin();
  Serial.begin(9600);
  serial_connection.begin(9600);
  Serial.println("Project Red Stop");
}
void loop() {
prev = val;
val = gps.speed.mph();
//int val = speedM;
 while(serial_connection.available())//While there are characters to come from the GPS
  {
    gps.encode(serial_connection.read());//This feeds the serial NMEA data into the library one char at a time
  }
  if(val <= 0)
  //   if(speedM < 5 & val--)
  {
    Serial.println("Speed MPH:");
    Serial.println(gps.speed.mph());
    Serial.println("Satellite Count:");
    Serial.println(gps.satellites.value());
    Serial.println("Latitude:");
    Serial.println(gps.location.lat(), 6);
    Serial.println("Longitude:");
    Serial.println(gps.location.lng(), 6);
    colorWipe(strip.Color(0,100,0), 100);                
   // strip.setPixelColor(0, strip.Color(0,100,0));                   // gps works faster with this: 
    strip.show();
    delay(10);
  }
  else if(val < prev) {
    Serial.println("Speed MPH:");
    Serial.println(gps.speed.mph());
    Serial.println("Satellite Count:");
    Serial.println(gps.satellites.value());
    Serial.println("Latitude:");
    Serial.println(gps.location.lat(), 6);
    Serial.println("Longitude:");
    Serial.println(gps.location.lng(), 6);
    colorWipe(strip.Color(0,100,0), 100);                
   // strip.setPixelColor(0, strip.Color(0,100,0));                   // gps works faster with this: 
    strip.show();
    delay(10);
  }
  else if(val > 0) 
  //   else if(speedM > 5 & val++) 
  {
    Serial.println("Speed MPH:");
    Serial.println(gps.speed.mph()); 
    Serial.println("Satellite Count:");
    Serial.println(gps.satellites.value());
    Serial.println("Latitude:");
    Serial.println(gps.location.lat(), 6);
    Serial.println("Longitude:");
    Serial.println(gps.location.lng(), 6); 
    colorWipe(strip.Color(0,100,100), 100);
    strip.show();
    delay(10);
  }
  else if(val > prev) {
      Serial.println("Speed MPH:");
    Serial.println(gps.speed.mph()); 
    Serial.println("Satellite Count:");
    Serial.println(gps.satellites.value());
    Serial.println("Latitude:");
    Serial.println(gps.location.lat(), 6);
    Serial.println("Longitude:");
    Serial.println(gps.location.lng(), 6); 
    colorWipe(strip.Color(0,100,100), 100);
    strip.show();
    delay(10); 
  }
}
void colorWipe(uint32_t color, int quick) {
  for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
    strip.setPixelColor(i, color);         //  Set pixel's color (in RAM)
    strip.show();                          //  Update strip to match
    delay(0);                           //  Pause for a moment
  }
}

speedometer_LI (3).jpg

val = gps.speed.mph();

Don’t do this until you’ve checked that the GPS has some valid data.

  if(val <= 0)

//  if(speedM < 5 & val–)

How can speed ever be less than zero?

The commented-out line is even less sensible. Did “val” used to do a different function in the first version of this? Then delete this code. If you un-commented it in an attempt to go back to the previous version, this will decrement the value of val and really screw things up.

Note also “&” is a bit-wise and. Not a logical and. Arduino does allow you to use “and” to mean “&&” but that usage is discouraged as it won’t work if you ever try to program on a regular C or C++ system.

The remaining un-commented code seems to compare val to the previous value of val. 10 milliseconds ago, you didn’t get any new GPS updates so val is almost always going to be exactly equal to prev.