You are reading a single comment by @Frida and its replies. Click here to read the full conversation.
  • I have now tested my Wii Nunchuck on my Pico and esp8266, and now I have it running on both.
    I had to set the freq to 80 on esp8266 and put in a few delay's.

    // nunchuk_03 -     pico - esp8266-01
    
    //White:	Gnd  -  Gnd
    //Red:		3V3  -  Vdd
    //Yellow:	SCL  -  B6  -  D0
    //Green:	SDA  -  B7  -  D2
    
    
    function Wait(ms) {
      var a = Date().getTime() + ms;
      while(Date().getTime() < a) {}
    }
    
    var d;
    var a;
    
    (function() {
      var tg = 0x2F; // 0x2F ^ 0x73 = 0x5C
      var esp8266 = true;
    
      if(esp8266) {
        // esp8266
        var ESP8266 = require('ESP8266');
        ESP8266.setCPUFreq(80);
        pinMode(D0, 'opendrain'); // scl
        pinMode(D2, 'opendrain'); // sda
        I2C1.setup({scl:D0,sda:D2});
      }
      else {
        // pico
        I2C1.setup({scl:B6,sda:B7});
      }
    
      // pico and esp8266-01
      var i2c = I2C1;
      i2c.writeTo(0x52, [0xF0, 0x55]);
      Wait(11);
      i2c.writeTo(0x52, [0xFB, 0x00]);
      Wait(11);
    
      setInterval(function() {
    
        i2c.writeTo(0x52, [0x00]);
        Wait(1);
        d = i2c.readFrom(0x52, 6);
        tg ^= 0x73;
        console.log(d, ' ', String.fromCharCode(tg));
        console.log({
          joy : {x:d[0],y:d[1]},
          acc : {x:(d[2]<<2)+((d[5]>>2)&3),
                 y:(d[3]<<2)+((d[5]>>4)&3),
                 z:(d[4]<<2)+((d[5]>>6)&3)},
          btn : {z:!(d[5]&1),c:!(d[5]&2) }
        });
    
      },500);
    
    })();
    
    

    1 Attachment

    • picb.png
About

Avatar for Frida @Frida started