Do you have a resistor pulling C1 down to ground as well? That's usually needed, otherwise the signal will just 'float' when the button isn't pressed.
Espruino has resistors internally that can be used, so all you need to do is to replace your pinMode command with: pinMode(C1, "input_pulldown");.
Also, I'd remove the pinMode command from onInit and would just execute it normally - Espruino will automatically remember the state of pins when you type save anyway, so there's no need to set them on startup.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Do you have a resistor pulling C1 down to ground as well? That's usually needed, otherwise the signal will just 'float' when the button isn't pressed.
Espruino has resistors internally that can be used, so all you need to do is to replace your
pinMode
command with:pinMode(C1, "input_pulldown");
.Also, I'd remove the pinMode command from
onInit
and would just execute it normally - Espruino will automatically remember the state of pins when you type save anyway, so there's no need to set them on startup.