Avatar for ancienthero

ancienthero

Member since Apr 2017 • Last active May 2017
  • 1 conversations
  • 3 comments

Most recent activity

  • in Projects
    Avatar for ancienthero

    I was wondering how to code given behaviour:
    increment counter when button is pressed
    keep incrementing when button is held down

    such a behaviour is often implemented for setting hours etc.

    I've tried this:

    var presses=0;
    //presses count
    pinMode(A7, "input_pulldown");
    // software pulldown
    
    setWatch(function(){
      clearInterval();
      presses++;
      setInterval(function(){
        if(digitalRead(A7)) {
          presses++;
          console.log(presses);
        } else {clearInterval();}
      }, 500);
      console.log(presses);
    },A7,{ repeat : true, debounce : 30, edge : "rising" }  );
    

    It works... but it's clearing other intervals.
    Is there a cleaner/better way to code this?
    If you know how to code it better, or have your own solution please share

    Thanks

  • in General
    Avatar for ancienthero

    Thanks @Gordon

    am I getting it right?

    btw, is there a way to check if it's successfully detected and used?

  • in General
    Avatar for ancienthero

    Hi

    I'm building a Programmable Timer Switch (Synchronizing time with DCF77 - from time to time) on espruino Pico so I need a quite accurate clock.
    Do I need a external RTC (like DS1307 or DS3231) or internal crystal is accurate enough for a clock?
    I'm quite confused because here we've got: espruino.com/Pico+Clock

    While the Pico has an RTC built in, by default it doesn't have an accurate watch crystal and so uses its internal oscillator which isn't that accurate. It won't keep proper time over a month

    but, on the other hand, there is a clock frequency crystal in schematic - which should generate very accurate time

    Thanks for your help

Actions