Avatar for ThePlayShed

ThePlayShed

Member since Nov 2019 • Last active Jul 2020
  • 2 conversations
  • 15 comments

Dad of two little girls, I make random toys in my spare time

Most recent activity

  • in Projects
    Avatar for ThePlayShed

    Thanks I've changed it to javascript

    the direction works between the number so grater that 100 but less that 200 set this speed

    ie

    if (dir_val < 200 && dir_val > 100) {
              const sendvalue = new Uint8Array([0x08, 0x00, 0x81, 0x00, 0x01, 0x51, 0x00, 0xce]);
      }
    
  • in Projects
    Avatar for ThePlayShed

    Hi All

    A while ago i promised i would write up some info about a toy I made my kids for Christmas, It's a bluetooth remote that controls a lego duplo train. It works on a MDBT42Q coding in Espruino. I finally got round to doing it on instructables

    https://www.instructables.com/id/Wooden-­Bluetooth-Remote-for-Lego-Duplo-Train/

    Any feedback or question would very welcomed I've also entered in to toy and games contest so any votes would be very much appreciated

    Once again thanks for all the help via this forum when I was making project

    Many Thanks

    James

  • in General
    Avatar for ThePlayShed

    Sorry for late rely, yes I ditched the NRF.nfcSend, and used characteristic.writeValue, I will get my code together and try and write up brief tutorial

  • in General
    Avatar for ThePlayShed

    Thanks Robin, that eventually worked however i realise i was missing a step and had to send a two different commands to make it work.

    I managed to get me remote made in time for christmas so thank you all for you help, here a video of my remote in action

    https://www.instagram.com/p/B6inY2XgasT/­?igshid=16amjui8jcves

    I hope you all had great a christmas

  • in General
    Avatar for ThePlayShed

    Thanks for replying

    unfortantly it does like Array.from unless is need to done a slight different way in espruino

    Uncaught Error: Function "from" not found!
    at line 7 col 19
    var myArr = Array.from("ABCDEFG");

  • in General
    Avatar for ThePlayShed

    Sorry To keep asking,

    I am seem to making some progress using a paired back node script and now rewriting in to use on the espruino, however I am stuck finding a way of making 'Buffer.from' working, Is there espruino equivalent ?

    I am looking to run this line

    const sounddata = Buffer.from([0x08, 0x00, 0x81, 0x01, 0x11, 0x51, 0x01, 0x05]);
    
  • in General
    Avatar for ThePlayShed

    Thanks For have a look Robin is this a better layout ?

    var devices;
    var gatt;
    var DevName="e0:7d:ea:0c:03:29";
    var serviceUUID="00001623-1212-efde-1623-785­feabcd123";
    var characteristicUUID="00001624-1212-efde-1­623-785feabcd123";
    var MessageToSend=[0x81, 0x00, 0x11, 0x51, 0x00, 0x64];
    pinMode(D15, 'input_pulldown');
    global.LED2=D2;
    
    NRF.connect("e0:7d:ea:0c:03:29").then(fu­nction(g) {
      console.log("Starting connecting");
      gatt = g;
      return gatt.getPrimaryService("00001623-1212-ef­de-1623-785feabcd123");
    }).then(function(service) {
      return service.getCharacteristic("00001624-1212­-efde-1623-785feabcd123");
    }).then(function(characteristic) {
      return characteristic.writeValue(MessageToSend)­;
    }).then(function() {
      //gatt.disconnect();
      console.log("Done!");
    });
    
    function send_message() {
      console.log("Moving Train");
      NRF.nfcSend(new Uint8Array([0x81, 0x00, 0x11, 0x51, 0x00, 0x64]));
    }
    
    function train_disconnect() {
      console.log("Disconnecting");
      gatt.disconnect();
    }
    
    setInterval(function() {
      digitalWrite(LED2, digitalRead(D15));
      if (digitalRead(D15) == 1) {
        send_message();
      }
      console.log("Button pressed", digitalRead(D15));
    }, 300);
    
  • in General
    Avatar for ThePlayShed

    Hi All

    Thanks allobjects that helped but my progress is still quite slow, i have managed to connect to the train and disconnect but can't work out the best way to send the buffer. I am still trying to get my head around javascript so maybe missing something quite obvious

    here's my current code

    var devices;
    var gatt;
    var DevName="e0:7d:ea:0c:03:29";
    var serviceUUID="00001623-1212-efde-1623-785­feabcd123";
    var characteristicUUID="00001624-1212-efde-1­623-785feabcd123";
    var MessageToSend=[0x81, 0x00, 0x11, 0x51, 0x00, 0x64];
    pinMode(D15, 'input_pulldown');
    global.LED2=D2;

    NRF.connect("e0:7d:ea:0c:03:29").then(fu­nction(g) {
    console.log("Starting connecting");
    gatt = g;
    return gatt.getPrimaryService("00001623-1212-ef­de-1623-785feabcd123");
    }).then(function(service) {
    return service.getCharacteristic("00001624-1212­-efde-1623-785feabcd123");
    }).then(function(characteristic) {
    return characteristic.writeValue(MessageToSend)­;
    }).then(function() {
    //gatt.disconnect();
    console.log("Done!");
    });

    function send_message() {
    console.log("Moving Train");
    NRF.nfcSend(new Uint8Array([0x81, 0x00, 0x11, 0x51, 0x00, 0x64]));
    }

    function train_disconnect() {
    console.log("Disconnecting");
    gatt.disconnect();
    }

    setInterval(function() {
    digitalWrite(LED2, digitalRead(D15));
    if (digitalRead(D15) == 1) {

    send_message();
    

    }
    console.log("Button pressed", digitalRead(D15));
    }, 300);

    any advice would be greatly appreciated

    Cheers

    James

  • in General
    Avatar for ThePlayShed

    Thanks the lego link very helpful

    Yes it looks like the message it send contains the 16 bytes in hex followed buffer string that appears to vary in length. ie Buffer 05 00 01 02 02 or 0a 00 41 00 00 01 00 00 00 01

    sorry didn't realise i was using two account the previous message was sent from my work.

Actions