trying to program button on joystick to controll servo

the problem on my code is:

int button1 = D2; //button pin, connect to ground to move servo

and the error message is:

exit status 1
'D2' was not declared in this scope

help?

D2 os not a number and or it is not defined
try:

// near the top of your code add:
#define D2 6 // Anytime D2 appears it will be replaced by the number 6 for Arduino Pin 6 in you case
//... other code
int button1 = D2;   //button pin, connect to ground to move servo

or

int button1 = 6;   //button pin, connect to ground to move servo number 6 for arduino Pin 6 in you case

Z