• Update:

          I've added : pinMode(Cx, 'input_pulldown');
    

    for each input I've used, and changed the debounce to 200. Now it looks stable !!! :)

  • Fri 2019.08.09

    'process.memory() ={ free: 1608, usage: 632, total: 2240, history: 43,'

    Thank you for posting the memory check. Nothing out of the ordinary there for the Original Espruino board. What were the results of continued observation? I'm guessing no leaks, as a solution was finally found.

    'I've added : pinMode(Cx, 'input_pulldown');'

    With as many combinations of pinMode() that are available, it is always a good idea to check the chip datasheet, link found beneath 'Information' heading towards the end of each specific Espruino board info page. A little study here goes a long way to understanding.

    p.86

    https://www.espruino.com/datasheets/STM3­2F103xC.pdf

    It can be see the internal resistance is 30-50K with 40K being nominal. So depending on the design, in this case it sounds like the pin was just connected to the V+ side of the button, thus when specifying 'pulldown' the input signal to the pin would now be stable.

    'There's no external resistor attached to the buttons. Is this needed?'

    Depends on your design requirements.

    In general however, without the appropriate pinMode() a 40K resistance allows for a very small current, but must be overcome in order to change the detectable state. Having a direct short is not advisable, although will provide what appears to be the results one is after. It is always a good idea to use a current limiter when yanking a pin to any state, so the processor is protected. This also prevents shorting your supply and activating your home ceiling smoke detector!

    Use Ohm's Law here to calculate the appropriate size based on the voltage detected. Somewhere from ~1K -> ~4.7K -> ~10K would be in the right range, and low enough a value to provide enough current to override the internal ~40K nominal value.

About

Avatar for PeterD @PeterD started