Press button to control LED ON AND OFF

i have to do a project to make my LED flash when push button pressed and push button not pressed =LED off
i try a code like this
const int buttonPin = 16; // 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);
}
}

but it does not work. Then i ask my friend he give me this code(below) and he told me i will understand the difference between his code and my code .but i really don't understand what mistake i make
void setup()
{
// Initialize serial and wait for port to open:
Serial.begin(115200);
while (!Serial)
{
; // wait for serial port to connect. Needed for native USB port only
}

// Set pins
pinMode(LED_Out_Pin, OUTPUT);
pinMode(SW_In_Pin, INPUT_PULLUP);
}

how is pinMode different?

It is hard to know what is going on without a schematic or the rest of the code but it appears that one program sets the mode for the button pin to INPUT (the state after a reset and would require a pulldown resistor according to the code) and the other program sets the mode for the button pin to INPUT_PULLUP (and presumably the code acts on a LOW instead of on a HIGH).

here is the schematic

schematic of what? Why did you choose pin 16?

schematic of PCB

here is the photo

aarg:
schematic of what? Why did you choose pin 16?

i just see the schematic and guess it is pin 16..

With a schematic such as that, a lot of guessing would be needed.

I used to be an electrical engineer for about forty years and left voluntarily. If I had provided a schematic such as that, I would have had to worry about my continued employment.