Counter gone haywire

I have a fairly simple sketch, how is works is that I'm digitally reading a sensor, when it's equal to 1 do something (light some strip LED's in a certain pattern), when it's 0, turn off the LED's. I also have a counter in place to switch from one pattern to another. IE when the counter is under 20, do one pattern, when it's over 20 do another.

My problem is that my counter is going haywire. When I'm monitoring it in the serial monitor it does a crazy jump - here is the output below (ignore all the other data, it's just the counter that is relevant.) As you see it jumps from 73 up to 4938, seemingly for no reason...

Value: 0, Volts: 0.00, Counter: 72, Old: 0, degrees C: -50.00
sensor Value: 1, Volts: 0.00, Counter: 73, Old: 0, degrees C: -49.51
sensor Value: 0, Volts: 0.00, Counter: 73, Old: 1, degrees C: -50.00
Value: 0, Volts: 0.00, Counter: 73, Old: 1, degrees C: -50.00
sensor Value: 1, Volts: 0.00, Counter: 4938, Old: 0, degrees C: -49.51
sensor Value: 1, Volts: 0.00, Counter: 4938, Old: 1, degrees C: -49.51
sensor Value: 1, Volts: 0.00, Counter: 4938, Old: 1, degrees C: -49.51
sensor Value: 1, Volts: 0.00, Counter: 4938, Old: 1, degrees C: -49.51

Here's my whole sketch, any help would be appreciated:

#include "FastLED.h"
#define NUM_LEDS 30  // # of LEDS in the strip
CRGB leds[NUM_LEDS];
CRGB leda[NUM_LEDS];
#define PIN 10
#define PINA 11 // Output Pin to Data Line on Strip
#define COLOR_ORDER GRB  // I had to change this for my strip if your color is off then you know.
// named constant for the pin the sensor is connected to
const int sensorPin = A0;
// room temperature in Celsius
const float baselineTemp = 20.0;
int counter = 0;
 int oldsensorVal = 0;

void setup() {
   FastLED.addLeds<WS2812B, PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
    FastLED.addLeds<WS2812B, PINA, COLOR_ORDER>(leda, NUM_LEDS).setCorrection( TypicalLEDStrip );
  // open a serial connection to display values
  Serial.begin(9600);
  // set the LED pins as outputs
  // the for() loop saves some extra coding
  for (int pinNumber = 2; pinNumber < 5; pinNumber++) {
    pinMode(pinNumber, OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
}

void loop() {
  // read the value on AnalogIn pin 0 and store it in a variable
  int sensorVal = digitalRead(sensorPin);

  // send the 10-bit sensor value out the serial port
  Serial.print("sensor Value: ");
  Serial.print(sensorVal);

  // convert the ADC reading to voltage
  float voltage = (sensorVal / 1024.0) * 5.0;

  // Send the voltage level out the Serial port
  Serial.print(", Volts: ");
  Serial.print(voltage);

    Serial.print(", Counter: ");
  Serial.print(counter);
      Serial.print(", Old: ");
  Serial.print(oldsensorVal);
  // convert the voltage to temperature in degrees C
  // the sensor changes 10 mV per degree
  // the datasheet says there's a 500 mV offset
  // ((voltage - 500 mV) times 100)
Serial.print(", degrees C: ");
  float temperature = (voltage - .5) * 100;
 Serial.println(temperature);

if (sensorVal == 0 and counter < 20)  {
 

  
int  r= random(0,255);
int g= random(0,255);
int b= random(0,255); 

byte randNum = random(0, 2); //randomly selects between specific colors
   switch (randNum)
   {
      case 0:
         r=0;
         break;
      case 1:
        g=0;
         break;
      case 2:
        b=0;
         break;
   }
  
 for(int i = 0; i < NUM_LEDS; i++ )
   {   leds[i] = CRGB(r,g,b); 
        } FastLED.show(); 

        counter ++;
}

///Fast kitt for second effect...

if (sensorVal == 0 and counter > 19 and counter <40)  {

for(int i = 0; i < NUM_LEDS; i++ )
   {   leds[i] = CRGB(255,0,0);
      FastLED.show(); 
   delay (5);
   leds[i-1] = CRGB(0,0,0); 
        } FastLED.show(); 
counter ++;
         
  
}

///RAndomoly light any light any color


if (sensorVal == 0  and counter > 39 and counter <100)  {



  
int  r= random(100,255);
int g= random(100,255);
int b= random(100,255); 

byte randNum = random(0, 2); //randomly selects between specific colors
   switch (randNum)
   {
      case 0:
         r=0;
         break;
      case 1:
        g=0;
         break;
      case 2:
        b=0;
         break;
   }

int rando = random (0,NUM_LEDS);
   {   leds[rando] = CRGB(r,g,b);

   leds[rando+10] = CRGB(r*1.3,g-30,b+30);
     
        } FastLED.show(); 

        delay (100);
counter ++;
         
  
}





if (sensorVal ==1 ) {
  for(int i = 0; i < NUM_LEDS; i++ )
  {   leds[i] = CRGB(0,0,0); 
      } FastLED.show(); 

}

 if (counter == 100) { counter = 0;}
 oldsensorVal = sensorVal;
}

if nothing else, you could do something like

Serial.print("A: ");Serial.println(counter);

at each place where counter implements, but with a different leading letter.

One of these is surely spewing, and this will tell you which one.

Thanks for the reply, I actually figured it out - I had some sloppy code in the //Randomly light any light any color section that was causing things to go loopy.

int counter = 0;
use
byte counter = 0;

if (counter == 100) { counter = 0;}
use
if (counter >= 100) { counter = 0;}

const int sensorPin = A0;

void loop() {
  // read the value on AnalogIn pin 0 and store it in a variable
  int sensorVal = digitalRead(sensorPin);

  // convert the ADC reading to voltage
  float voltage = (sensorVal / 1024.0) * 5.0;

A 'digitalRead()' on pin A0 will only get you 0/LOW/false or 1/HIGH/true. Use analogRead() to get an ADC reading from the analog input pins.