Is my arduino psychic?

I just got my Arduino and I am following a tutorial on youtube. Pretty much like a “hello world” program. Here’s the code:

int toggle = 8; //Toggles the LED on/off
int led = 13;

void setup() {
// put your setup code here, to run once:
pinMode(toggle, INPUT);
pinMode(led, OUTPUT);

void loop() {
if(digitalRead(toggle) == HIGH)
digitalWrite(led, HIGH);

Basically it’s supposed to turn the LED on if the button is pressed, and off when the button is not pressed.

However, when I plug a copper wire into pin 8, the LED on the unit stays on. The weird part is when I plug a resistor in pin 8 (not connected to anything). The LED only turns on when my hands are near the resistor. It’s like it can detect my proximity… Anyone ever run into this issue?

It's because you have a floating input. You need to either add an external pull-up or pull-down resistor (depending on how your button is wired) or else turn on the internal pull-up resistor using pinMode(toggle, INPUT_PULLUP);

Please read:

yes, it sees electromagnetic ghosts with floating pin acting as an antenna

You could start a TV show with that Arduino setup.

I've seen others do it, with 'spirit boxes' and whatnot.