Avatar for Marty_McFly

Marty_McFly

Member since Jan 2017 • Last active Jul 2018
  • 32 conversations
  • 67 comments

Most recent activity

  • in Interfacing
    Avatar for Marty_McFly

    Yeah, I'll try that. How accurate is the crystal? How long will it last before it drifts off? Also, are the capacitors required? I read another forum thread where someone else's crystal only worked after adding the capacitors, but in the documentation it says they aren't.

  • in Interfacing
    Avatar for Marty_McFly

    Hi,
    How do I detect two simultaneous button presses? I've tried putting a setWatch() inside another setWatch(), but the inner watch still activates even when I don't trigger the outer one. Any tips?

    Thanks!

  • in Interfacing
    Avatar for Marty_McFly

    Oh well. I guess I'll use the MDBT42Q module for my future projects then.
    Is there any way for the pico to keep accurate time then? I found out that the pico tends to be about a minute late every 43 minutes from calibration. Will it be possible to write code to add a minute to the time every 43 minutes? Is it even possible?

    Thanks!

  • in Interfacing
    Avatar for Marty_McFly

    Do you think a simple software solution can be added? For example, add 5 minutes to the time every 10 hours or so?

  • in Interfacing
    Avatar for Marty_McFly
    
    var dg1 = A8;
    var dg2 = B7;
    var A = B14;
    var B = B13;
    var C = B10;
    var D = B1;
    var E = A7;
    var F = A6;
    var G = A5;
    var DP =  B15;
    
    function allClear() {
      digitalWrite(A , 0);
      digitalWrite(B , 0);
      digitalWrite(C , 0);
      digitalWrite(D , 0);
      digitalWrite(E , 0);
      digitalWrite(F , 0);
      digitalWrite(G , 0);
      digitalWrite(DP , 0);
      digitalWrite(A8, 1);
      digitalWrite(B7, 1);
    }
    
    /*
    A little help?
    
                ----A----
                |       |
                F       B
                |       |
                ----G----
                |       |
                E       C
                |       |
                ----D----
    */
    
    function one() {
      digitalWrite(F, 1);
      digitalWrite(E, 1);
    }
    
    function two() {
      digitalWrite(A, 1);
      digitalWrite(B, 1);
      digitalWrite(G, 1);
      digitalWrite(E, 1);
      digitalWrite(D, 1);
    }
    
    function three() {
      digitalWrite(A, 1);
      digitalWrite(B, 1);
      digitalWrite(G, 1);
      digitalWrite(C, 1);
      digitalWrite(D, 1);
    }
    
    function four() {
      digitalWrite(F, 1);
      digitalWrite(G, 1);
      digitalWrite(B, 1);
      digitalWrite(C, 1);
    }
    
    function five() {
      digitalWrite(A, 1);
      digitalWrite(F, 1);
      digitalWrite(G, 1);
      digitalWrite(C, 1);
      digitalWrite(D, 1);
    }
    
    function six() {
      digitalWrite(A, 1);
      digitalWrite(F, 1);
      digitalWrite(E, 1);
      digitalWrite(G, 1);
      digitalWrite(C, 1);
      digitalWrite(D, 1);
    }
    
    function seven() {
      digitalWrite(F, 1);
      digitalWrite(A, 1);
      digitalWrite(B, 1);
      digitalWrite(C, 1);
    }
    
    function eight() {
      digitalWrite(A, 1);
      digitalWrite(B, 1);
      digitalWrite(C, 1);
      digitalWrite(D, 1);
      digitalWrite(E, 1);
      digitalWrite(F, 1);
      digitalWrite(G, 1);
    }
    
    function nine() {
      digitalWrite(A, 1);
      digitalWrite(B, 1);
      digitalWrite(C, 1);
      digitalWrite(G, 1);
      digitalWrite(F, 1);
    }
    
    function zero() {
      digitalWrite(A, 1);
      digitalWrite(B, 1);
      digitalWrite(C, 1);
      digitalWrite(D, 1);
      digitalWrite(E, 1);
      digitalWrite(F, 1);
    }
    
    function aa() {
      digitalWrite(A, 1);
      digitalWrite(B, 1);
      digitalWrite(C, 1);
      digitalWrite(E, 1);
      digitalWrite(F, 1);
      digitalWrite(G, 1);
    }
    
    function bb() {
      digitalWrite(C, 1);
      digitalWrite(D, 1);
      digitalWrite(E, 1);
      digitalWrite(F, 1);
      digitalWrite(G, 1);
    }
    
    function cc() {
      digitalWrite(A, 1);
      digitalWrite(F, 1);
      digitalWrite(E, 1);
      digitalWrite(D, 1);
    
    }
    
    function data() {
      full=(new Date()).toString();
      words = full.split(' ');
      month = words[1];
      date = words[2];
      bigtime = words[4];
      small = words[4].split(':');
      hour = small[0];
      if (hour > 12) {
        hour = hour-12;
      }
      min = small[1];
    }
    
    /*
        digitalWrite(A8, 1);
        digitalWrite(B7, 0);
        three();
        allClear();
        digitalWrite(A8, 0);
        digitalWrite(B7, 1);
        five();
        allClear();
    */
    
    function hourDriver() {
      data();
      switch (Number(hour)) {
        case 00:
        case 12:
          allClear();digitalWrite(A8, 0);
          cc();
          break;
        case 01:
          allClear();digitalWrite(A8, 0);
          one();
          break;
        case 02:
          allClear();digitalWrite(A8, 0);
          two();
          break;
        case 03:
          allClear();digitalWrite(A8, 0);
          three();
          break;
        case 04:
          allClear();digitalWrite(A8, 0);
          four();
          break;
        case 05:
          allClear();digitalWrite(A8, 0);
          five();
          break;
        case 06:
          allClear();digitalWrite(A8, 0);
          six();
          break;
        case 07:
          allClear();digitalWrite(A8, 0);
          seven();
          break;
        case 08:
          allClear();digitalWrite(A8, 0);
          eight();
          break;
        case 09:
          allClear();digitalWrite(A8, 0);
          nine();
          break;
        case 10:
          allClear();digitalWrite(A8, 0);
          aa();
          break;
        case 11:
          allClear();digitalWrite(A8, 0);
          bb();
          break;
      }
    }
    
    function minuteDriver() {
      data();
      switch(Number(min)) {
        case 00:
        case 01:
        case 02:
        case 03:
        case 04:
          allClear();digitalWrite(B7, 0);
          break;
        case 05:
        case 06:
        case 07:
        case 08:
        case 09:
          allClear();digitalWrite(B7, 0);
          digitalWrite(G, 1);
          break;
        case 10:
        case 11:
        case 12:
        case 13:
        case 14:
          allClear();digitalWrite(B7, 0);
          digitalWrite(F, 1);
          break;
    
        case 15:
        case 16:
        case 17:
        case 18:
        case 19:
          allClear();digitalWrite(B7, 0);
          digitalWrite(F, 1);
          digitalWrite(G, 1);
          break;
    
        case 20:
        case 21:
        case 22:
        case 23:
        case 24:
          allClear();digitalWrite(B7, 0);
          digitalWrite(A, 1);
          break;
        
        case 25:
        case 26:
        case 27:
        case 28:
        case 29:
          allClear();digitalWrite(B7, 0);
          digitalWrite(A, 1);
          digitalWrite(G, 1);
          break;
        
        case 30:
        case 31:
        case 32:
        case 33:
        case 34:
          allClear();digitalWrite(B7, 0);
          digitalWrite(B, 1);
          break;
    
        case 35:
        case 36:
        case 37:
        case 38:
        case 39:
          allClear();digitalWrite(B7, 0);
          digitalWrite(B, 1);
          digitalWrite(G, 1);
          break;
        
        case 40:
        case 41:
        case 42:
        case 43:
        case 44:
          allClear();digitalWrite(B7, 0);
          digitalWrite(C, 1);
          break;
        
        case 45:
        case 46:
        case 47:
        case 48:
        case 49:
          allClear();digitalWrite(B7, 0);
          digitalWrite(C, 1);
          digitalWrite(G, 1);
          break;
        
        case 50:
        case 51:
        case 52:
        case 53:
        case 54:
          allClear();digitalWrite(B7, 0);
          digitalWrite(D, 1);
          break;
        
        case 55:
        case 56:
        case 57:
        case 58:
        case 59:
          allClear();digitalWrite(B7, 0);
          digitalWrite(D, 1);
          digitalWrite(G, 1);
          break;
      }
    }
    
    function random(state) {
      
      if (state === true || state === 1) {
        clearTimeout();
        random();
      } else if (state === false || state === 0) {
        allClear();
        clearTimeout();
        setDeepSleep(1);
        return;
      }
      
      var what = Math.floor((Math.random() * 3));
      
      if (what === 0) {
        allClear();
      }
      else if (what == 1 || what == 2) {
        digitalWrite(A, Math.floor((Math.random() * 2)));
        digitalWrite(B, Math.floor((Math.random() * 2)));
        digitalWrite(C, Math.floor((Math.random() * 2)));
        digitalWrite(D, Math.floor((Math.random() * 2)));
        digitalWrite(E, Math.floor((Math.random() * 2)));
        digitalWrite(F, Math.floor((Math.random() * 2)));
        digitalWrite(G, Math.floor((Math.random() * 2)));
      }
    
      setTimeout(random, ((Math.random() * 1000) + 1));
      
    }
    
    function swirl() {
      for (delay=35;delay>0;delay=delay-2) {
        digitalWrite(B14, 0);
        digitalWrite(B13, 1);
    
          digitalPulse(A1, 1, delay);
    
        digitalWrite(B13, 0);
        digitalWrite(B10, 1);
    
          digitalPulse(A1, 1, delay);
    
        digitalWrite(B10, 0);
        digitalWrite(B1, 1);
    
          digitalPulse(A1, 1, delay);
    
        digitalWrite(B1, 0);
        digitalWrite(A7, 1);
    
          digitalPulse(A1, 1, delay);
    
        digitalWrite(A7, 0);
        digitalWrite(A6, 1);
    
          digitalPulse(A1, 1, delay);
    
        digitalWrite(A6, 0);
        digitalWrite(B14, 1);
    
          digitalPulse(A1, 1, delay);
      }
      digitalWrite(B14, 0);
      for (i=0;i<8;i++){
        digitalWrite(D, 0);
        digitalWrite(A, 1);
          digitalPulse(A1, 1, 90);
        digitalWrite(A, 0);
        digitalWrite(G, 1);
          digitalPulse(A1, 1, 90);
        digitalWrite(G, 0);
        digitalWrite(D, 1);
          digitalPulse(A1, 1, 90);
      }
    }
    
    //var l = false;
    //setWatch( function(e) { l=!l; random(l);}, B8, {repeat:true, edge:'falling', debounce:100});
    
    function onInit() {
      data();
      digitalWrite(A8,0);
      digitalWrite(B7,0);
      swirl();
      digitalWrite(D, 0);
      setDeepSleep(1);
    }
    
    pinMode(B8, 'input_pullup');
    pinMode(B5, 'input_pullup');
    
    setWatch(function (e) {
      data();
      for(i=0;i<60;i++){hourDriver();minuteDri­ver();}
      allClear();
      setDeepSleep(1);
    }, B8, {edge:"falling", repeat:true, debounce:50});
    
    /*
    var state = false;
    setWatch(function (e) {
      state=!state;
      random(state);
      setDeepSleep(1);
    }, B5, {edge:"falling", repeat:true, debounce:50});
    */
    
    setInterval(function(e) {
      data();
    }, 1800000);
    
    setDeepSleep(1);
    
    save();
    
  • in Interfacing
    Avatar for Marty_McFly

    Hey everyone,
    I'm using the Espruino Pico's real time clock for my clock project. Basically when I press the button, the Pico shows the time on some 7-segment LEDs for about a second and goes back to deep sleep.

    function data() {
      full=(new Date()).toString();
      words = full.split(' ');
      month = words[1];
      date = words[2];
      bigtime = words[4];
      small = words[4].split(':');
      hour = small[0];
      if (hour > 12) {
        hour = hour-12;
      }
      min = small[1];
    }
    
    function hourDriver(){
    data();
    switch(Number(hour)) {
      //some code
      }
    }
    
    function minuteDriver(){
    data();
    switch(Number(min)) {
      //some code
      }
    }
    
    setWatch(function (e) {
      data();
      for(i=0;i<60;i++){hourDriver();minuteDri­ver();}
      allClear(); //initializes 7-segment display
      setDeepSleep(1);
    }, B8, {edge:"falling", repeat:true, debounce:50});
    

    No matter what I do, the time seems to be drifting off about 5 to 10 minutes after a full day of use. What did I do wrong??? Or is the Pico's clock not the most accurate?

    Thanks!

    If you want the entire code it's in the comment below.

  • in Interfacing
    Avatar for Marty_McFly

    Yeah, where you can control an X by Y matrix with (X+Y) pins. I'm just more used to it, that's all.

Actions