You are reading a single comment by @Andreas and its replies. Click here to read the full conversation.
  • 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

    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.

    Thanks a lot, Andreas

About

Avatar for Andreas @Andreas started