Hey everyone,

I am working on a project for one of my classes where I am making a simplified parking space availability counter with a simple RGB display. The board I am using is an Arduino Mega2560 with an Adafruit matrix shield, connected to a 16x32 RGB Matrix panel. For testing purposes, I am using a breadboard with two mini pushbuttons to simulate a car entering or exiting a lot. The last issue I am having is I am getting a constant increment after startup without giving any inputs. For example, I have my spaces variable initialized at 100. When I power up my board it will display 100 and then continuously increment up after each loop. I am convinced it is not an issue with my push buttons because when I press and hold the increment button it starts counting faster, and when I do the same with the decrement it starts alternating back and fourth (example: 101,100,101,100,.....). I've included a copy of my code bellow. Any help, recommendations, and feedback would be greatly appreciated. Thank you!

#include <RGBmatrixPanel.h>

#define CLK 11 // USE THIS ON ARDUINO UNO, CLK 11 on MEGA

#define OE 9

#define LAT 10

#define A A0

#define B A1

#define C A2

const int buttonPin1 = 40;

const int buttonPin2 = 41;

byte button1_State = LOW;

byte button2_State = LOW;

RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);

//number of parking spots

int x = 100;

void setup() {

matrix.begin();

// fix the screen with violet

matrix.fillScreen(matrix.Color333(7, 0, 7));

delay(500);

//fill the screen with black

matrix.fillScreen(matrix.Color333(0, 0, 0));

//yellow text

matrix.setCursor(8, 0);

matrix.setTextSize(1);

matrix.setTextColor(matrix.Color333(7, 4, 0));

matrix.print('U');

matrix.setTextColor(matrix.Color333(7, 4, 0));

matrix.print('N');

matrix.setTextColor(matrix.Color333(7, 4, 0));

matrix.print('A');

//violet text

matrix.setCursor(1, 9); // next line

matrix.setTextColor(matrix.Color333(4, 0, 7));

matrix.print('L');

matrix.setTextColor(matrix.Color333(4, 0, 7));

matrix.print('I');

matrix.setTextColor(matrix.Color333(4, 0, 7));

matrix.print('O');

matrix.setTextColor(matrix.Color333(4, 0, 7));

matrix.print('N');

matrix.setTextColor(matrix.Color333(4, 0, 7));

matrix.print('S');

delay(2000);

//fill the screen with black

matrix.fillScreen(matrix.Color333(0, 0, 0));

//declare what pins are (Input or Output)

pinMode(buttonPin1, INPUT);

pinMode(buttonPin2, INPUT);

Serial.begin(9600);

}

void loop() {

button1_State = digitalRead(buttonPin1);

button2_State = digitalRead(buttonPin2);

// counter increment if the pushbutton 1 is pressed.

if (button1_State == HIGH ) {

x++;

}

// counter decrement if the pushbutton 2 is pressed.

else if (button2_State == HIGH ) {

x--;

}

//no action

else {

x = x;

}

matrix.setCursor(1, 0); // start at top left, with one pixel of spacing

matrix.setTextSize(1); // size 1 == 8 pixels high

if (x > 0) {

//green text

matrix.setTextColor(matrix.Color333(4, 7, 0));

matrix.print(x);

```
matrix.setCursor(1, 8); // next line
matrix.setTextColor(matrix.Color333(4, 7, 0));
matrix.print('S');
matrix.setTextColor(matrix.Color333(4, 7, 0));
matrix.print('P');
matrix.setTextColor(matrix.Color333(4, 7, 0));
matrix.print('O');
matrix.setTextColor(matrix.Color333(4, 7, 0));
matrix.print('T');
matrix.setTextColor(matrix.Color333(4, 7, 0));
matrix.print('S');
```

}

else {

//red text

matrix.setTextColor(matrix.Color333(7, 0, 0));

matrix.print(x);

```
matrix.setCursor(1, 8); // next line
matrix.setTextColor(matrix.Color333(7, 0, 0));
matrix.print('S');
matrix.setTextColor(matrix.Color333(7, 0, 0));
matrix.print('P');
matrix.setTextColor(matrix.Color333(7, 0, 0));
matrix.print('O');
matrix.setTextColor(matrix.Color333(7, 0, 0));
matrix.print('T');
matrix.setTextColor(matrix.Color333(7, 0, 0));
matrix.print('S');
```

}

delay(1000);

//fill the screen with black

matrix.fillScreen(matrix.Color333(0, 0, 0));

}