ReadyToDie:
It was my fault, it was working. By the way I was using a 4.7k resistor.Other question (As robtillaart said):
void setup()
{
pinMode(button1, INPUT);
digitalWrite(button1, HIGH);
Serial.begin(31250);
}if button1 is an input, what does " digitalWrite(button1, HIGH);" do? If somebody can explain it.
Thanks everybody
This a kind of inverse logic.
Doing by this way, you don't need to use an external resistor between the button and the ground.
In that case, if the button is pressed, the value returned by digitalRead value will be LOW. When the button is depressed, the value returned by digitalRead will be HIGH.