In my application I would like to use four buttons C2, C3, C4 and C5.
The question is, what is the best way to set up these buttons? I tried
function onInit() {
//Set the buttons to 0
C2.write(0);
C3.write(0);
C4.write(0);
C5.write(0);
}
setWatch(function() {
l = l + 1;
}, C5, { repeat: true, edge: "falling", debounce:100});
setWatch(function() {
m = m + 1;
}, C4, { repeat: true, edge: "falling", debounce:100});
setWatch(function() {
n = n + 1;
}, C3, { repeat: true, edge: "falling", debounce:100});
setWatch(function() {
o = o + 1;
}, C2, { repeat: true, edge: "falling", debounce:100});
Each of the buttons is connected to V_bat on the one side and to C2,3,4 or 5 on the other side. But when I press a button (let's say the one connected with C2), the variable "o" does not increase when I press it the first time, when I press it again it jumps from 0 to 2, then it works and jumps from 2 to 3 and so on but with no reproducibly. I just want to increase by 1 when a button is pressed.
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.
Hi Espruinos!
In my application I would like to use four buttons C2, C3, C4 and C5.
The question is, what is the best way to set up these buttons? I tried
Each of the buttons is connected to V_bat on the one side and to C2,3,4 or 5 on the other side. But when I press a button (let's say the one connected with C2), the variable "o" does not increase when I press it the first time, when I press it again it jumps from 0 to 2, then it works and jumps from 2 to 3 and so on but with no reproducibly.
I just want to increase by 1 when a button is pressed.
Thanks a lot, Andreas