You are reading a single comment by @Maarten and its replies. Click here to read the full conversation.
  • Hi everyone!

    I'm trying to control this RGBW LED driver over IR from an Espruino Pico. I'm using the record-replay code provided in the tutorial, but it works only occasionally. Sometimes it works multiple times in a row, then nothing for another 100 attempts (spamming the command). Both the remote and the Pico generates the output 100000000111111110000001011111101 repeatedly. Below is the recorded times.

    var remoteTimes = [ 9.19055938720, 4.59480285644, 0.49400329589, 0.66375732421, 0.51665306091, 0.61249732971, 0.51975250244, 0.63776969909, 0.51999092102, 0.60963630676, 0.51832199096, 0.66399574279, 0.51784515380, 0.58650970458, 0.54264068603, 0.63991546630, 0.49114227294, 0.66661834716, 0.49209594726, 1.76048278808, 0.54454803466, 1.73950195312, 0.62084197998, 1.71089172363, 0.54550170898, 1.73473358154, 0.49304962158, 1.78909301757, 0.51975250244, 1.76239013671, 0.51879882812, 1.78813934326, 0.54359436035, 1.73664093017, 0.54454803466, 0.58555603027, 0.51689147949, 0.63896179199, 0.54836273193, 0.60939788818, 0.51784515380, 0.61225891113, 0.57125091552, 0.58460235595, 0.51879882812, 0.63800811767, 0.54550170898, 1.76048278808, 0.49591064453, 0.63610076904, 0.48923492431, 1.79100036621, 0.49018859863, 1.81484222412, 0.49114227294, 1.76525115966, 0.57220458984, 1.73377990722, 0.51593780517, 1.76620483398, 0.53882598876, 1.74140930175, 0.54454803466, 0.63610076904, 0.51879882812, 1.76239013671, 0.51784515380, 40.56835174560, 9.18006896972, 2.31838226318, 0.54264068603, 97.63717651367, 9.23538208007, 2.25925445556, 0.51975250244, 97.62954711914, 9.23728942871, 2.26211547851, 0.51784515380 ];
    
    var picoTimes = [ 9.33551788330, 4.55093383789, 0.36334991455, 0.69141387939, 0.49662590026, 0.65827369689, 0.47397613525, 0.68569183349, 0.47302246093, 0.65898895263, 0.44536590576, 0.71907043457, 0.46825408935, 0.63633918762, 0.49567222595, 0.66280364990, 0.46825408935, 0.71430206298, 0.44631958007, 1.84535980224, 0.47492980957, 1.79195404052, 0.55408477783, 1.76715850830, 0.49591064453, 1.79862976074, 0.41198730468, 1.87301635742, 0.44441223144, 1.84631347656, 0.44631958007, 1.84535980224, 0.47397613525, 1.81770324707, 0.47302246093, 0.60939788818, 0.49495697021, 0.68855285644, 0.49972534179, 0.65803527832, 0.47492980957, 0.63514709472, 0.52356719970, 0.63610076904, 0.46825408935, 0.71430206298, 0.47302246093, 1.82437896728, 0.44059753417, 0.68569183349, 0.44631958007, 1.84822082519, 0.41484832763, 1.90162658691, 0.41770935058, 1.84631347656, 0.50163269042, 1.76811218261, 0.44250488281, 1.87015533447, 0.44631958007, 1.79672241210, 0.49495697021, 0.68664550781, 0.47206878662, 1.84822082519, 0.44441223144, 41.44477844238, 8.44764709472, 2.25925445556, 0.44631958007, 99.74384307861, 7.26509094238, 2.18200683593, 0.46825408935, 99.71523284912, 7.28607177734, 2.20584869384, 0.44441223144 ];
    
    

    Pico code:

    pinMode(A5,"input_pullup");
    
    var times = [];
    /* The ID of the watch we're using to record IR. We want to
    turn it off while we transmit in case we record outselves! */
    var currentWatch;
    
    function startWatching() {
      currentWatch = setWatch(function(e) {
        // work out how long the pulse was, in milliseconds
        var pulseLen = 1000 * (e.time - e.lastTime);
        // then save it, if it was less than 1 second
        if (pulseLen < 1000) {
          times.push(pulseLen);
        } else {
          times = [];
        }
      }, A5, {repeat:true});
    }
    
    startWatching();
    
    function stopWatching() {
      clearWatch(currentWatch);
      currentWatch = null;
    }
    
    function replay() {
      //Stop timer
      if(currentWatch !== null) stopWatching();
       //Light up LED1
      digitalWrite(LED1,1);
      // Start the 38kHz square wave
      analogWrite(B8,0.9,{freq:38000});
      // Send the pulses
      digitalPulse(B9, 1, times);
      // Wait until pulsing is finished
      digitalPulse(B9, 1, 0);
      // Turn LED1 off
      digitalWrite(LED1,0);
    }
    
    

    Any suggestions?

    Thanks and best regards,
    Maarten

About

Avatar for Maarten @Maarten started