2 led's and 2 switches

int ledpin = 5; // D1(gpio5)
int button = 4; //D2(gpio4

why not use

int ledpin = D1; 
int button = D2; 

Then the code matches the schematic