Update: Tried it a new nano and it works fine printing the correct value. Looks like something was wrong with the uno. I couldn't figure out what exactly was wrong with the uno so it's going to the trash can.
Problem solved. Thanks for the suppport @ cattledog.