Digital read syntax??

val = digitalRead(10); Serial.println(val);

I assigned pin 10 to be an input and turned on the pullup resistors, and val is an integer, but with the above setup running in my main loop i get 0 in the serial monitor whether I bring pin 10 to ground or not. If i change the serial monitor to show: Serial.println(digitalRead(10)); then it displays as it should when I'm changing the pin high and low.

Does anyone have any idea what's going on? It seems to work in other programs this way but not in mine. Any help would be appreciated. Thank you!

Post all the code, please.

An integer? Do you mean int, unsigned int, char, unsigned char, long, unsigned long, or something else? We cannot read code you haven't posted so please do so!

try Serial.println(val, DEC); // forces it to print as a decimal

if val is a byte you can get trouble as it tries to print char 0 or char 1 both invisible chars