Replacing a pushbutton with a on/off rocker switch

My suggestion uses No resistor, just the internal pullup resistor

in void setup:

pinMode (pinX, INPUT_PULLUP); // use with button connected to pinX and to Gnd

in void loop:

if ( digitalRead(pinX) == 0) {
// button was pressed
//do whatever the action is
}