write buttonState