Strange DigitalRead output

Hi

I have some code that reads the digital pins on my arduino ( have tried on both uno and nano )

( Please note the code referencing the graphics drivers is there as my ultimate intention is to generate graphics output to my display based on the digital inpiut values received )

When i run the code below on the serial monitor without there being anything attached to any of the digital pins the code outputs to screen results indicating that the if condition for digital_4 input is true when in fact its not.

Just wondering if anyone can advise what may be the issue and steps to rectify

"#include "U8glib.h"
U8GLIB_SSD1351_128X128_332 u8g(13, 11, 8, 9, 7); // Arduino UNO: SW SPI Com: SCK = 13, MOSI = 11, CS = 8, DC = 9, RESET = 7 (http://electronics.ilsoft.co.uk/ArduinoShield.aspx)

int digital_4= HIGH ;
int digital_5=HIGH ;
int digital_6=HIGH ;
int digital_7=HIGH ;
int digital_8=HIGH ;
int digital_9=HIGH ;
int digital_10=HIGH ;
int digital_11=HIGH ;

void setup() {
//start serial connection
Serial.begin(9600);
//configure pin 4 as an input and enable the internal pull-up resistor
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode(11, INPUT);
// pinMode(13, OUTPUT);

// assign default color value
if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
u8g.setColorIndex(255); // white
}
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
u8g.setColorIndex(3); // max intensity
}
else if ( u8g.getMode() == U8G_MODE_BW ) {
u8g.setColorIndex(1); // pixel on
}
else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
u8g.setHiColorByRGB(255,255,255);
}
}

void loop() {
//read the pushbutton value into a variable
digital_4 = digitalRead(4);
digital_5 = digitalRead(5);
digital_6 = digitalRead(6);
digital_7 = digitalRead(7);
digital_8 = digitalRead(8);
digital_9 = digitalRead(9);
digital_10 = digitalRead(10);
digital_11 = digitalRead(11);

if (digital_4 == LOW) {
Serial.println("speed zones: 40");
Serial.println();
}
else if (digital_5 == LOW) {
Serial.println("speed zoned: 50");
Serial.println();
}
else if (digital_6 == LOW) {
Serial.println("speed zoned: 60");
Serial.println();
}
else if ((digital_5 and digital_6) == LOW) {
Serial.println("speed zoned: 70");
Serial.println();
}
else if (digital_8 == LOW) {
Serial.println("speed zoned: 80");
Serial.println();
}
else if (digital_9 == LOW) {
Serial.println("speed zoned: 90");
Serial.println();
}
else if (digital_10 == LOW) {
Serial.println("speed zoned: 100");
Serial.println();
}
else if (digital_11 == LOW) {
Serial.println("speed zoned: 110");
Serial.println();
}

}"

Set pinMode(INPUT_PULLUP) to enable internal pullups. Pins configured as INPUT and not connected are "floating" and the state is undefined.

Try to remember to use code tags when posting code. Post the entire program.

without there being anything attached to any of the digital pins the code outputs to screen results indicating that the if condition for digital_4 input is true when in fact its not

If you have nothing connected to a pin configured only for INPUT, the state that you read is random (unpredictable).

If you have nothing connected to a pin configured for INPUT_PULLUP, it will read as HIGH. Connect it to ground to read as LOW.

The forum tells me that you have six posts. You should know to use code tags and post ALL of your code. Your original code probably did not have emoji.