Voltage on pins despite being on 'low'

Hey guys,

Just getting back into Arduino and I have lots of these typical fake Nano boards. I was trying to build a project when I noticed that a digital pin that was meant to be low was still leaking enough current to have an LED turn on. I booted up the 'Button' example code that comes with the IDE and even with the button turned off, the LED stays on, although it gets dimmer and flickers a bit. I've tried changing the pin the LED is on and tried a new board but the same problem persists. So all the button does is make the LED a bit brighter when pressed.
I did notice that only the pins mentioned in the code do this, so for example D6 isn't mentioned and when I plug an LED in nothing happens.
Maybe there has been an update with Arduino to stop fake boards? but I thought they were all basically the same microprocessors anyway.

So yeah ive attached the code below and was wondering if anyone could help! Thanks, Tintin.

BUT ITS NOT A CODE PROBLEM BECUASE ITS EXAMPLE CODE

const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}

void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}

Futhermore, I have just noticed that the 'L' led on the actual board itself does the same thing: not completely off ever but gets brighter when the button is pressed and dimmer/flickery and its released when the LED on the Dpin should be off (but isn't)

Tell us that you ONLY have +5 volts connected to the 5 volt pin and the -5volts connected to the board ground and noting else connected.

Paul

Hi Paul, thanks for the reply.

I have figured that this only happens when the board is being powered by the USB port. I am now powering it thorugh Vin with a 9V battery. it does turn completely off now, however the LED takes a few seconds to turn off despite a very short press on the button (there is no delay in the code). Might you know why this is? also why I cannot power it though the USB port?

many thanks,
Tintin

PS the only thing the 5V port connects to is the D2 pin via a button (to get the 'high')

I have also noticed that even when the button is not pressed, if I just connect the wire from it to the D2 pin the LED lights up, despite there being no pd between them. Very strange. It sort of just turns on at random times when ever it wants,

Is there a pull-down resistor on the button pin?

Clearly not, this is the result of not understanding floating inputs.

Use INPUT_PULLUP for the button pin mode, and then the button will work. However it will read LOW when pressed, HIGH when idle.