If your switch is activated randomly, hook a pull-down resistor to avoid EMI (VCC is 3.3V for a DUE):
Next is the debouncing issue:
https://forum.arduino.cc/index.php?topic=138887.0
If your switch is activated randomly, hook a pull-down resistor to avoid EMI (VCC is 3.3V for a DUE):
Next is the debouncing issue:
https://forum.arduino.cc/index.php?topic=138887.0