Avatar for JackJamesHoward

JackJamesHoward

Member since Aug 2014 • Last active Nov 2017
  • 8 conversations
  • 33 comments

I am a Mechanical Engineer
I may crack electronics one day, who knows?

Most recent activity

  • in Electronics
    Avatar for JackJamesHoward

    I was reading about these x27.168 automotive stepper motor gauges and noticed that adafruit suggests that you may be able to drive directly from a microcontroller (allowing for the appropriate kickback diodes.)

    Would anybody know if its possible to do directly from the puck.js?

  • in Puck.js
    Avatar for JackJamesHoward

    Thanks for your help Gordon. This is a nice little example to do with the puck by itself.
    For anyone else, finished code to be used along with the adafruit bluefruit app is below.

    NRF.on('connect', function(addr) { 
      LoopbackA.setConsole();
    });
    
    setWatch(function() {
      Bluetooth.setConsole();
    }, BTN, {repeat:true, edge:"rising", debounce:50});
    
    
    Bluetooth.on('data', function(d) { 
      if (d[0]=="!" && d[1]=="B") {
        var b = d.substr(2,2);
        if (b[0]=="1") LED1.write(0|b[1]);
        if (b[0]=="2") LED2.write(0|b[1]);
        if (b[0]=="3") LED3.write(0|b[1]);
        if (b[0]=="4") digitalWrite([LED1, LED2, LED3], b[1]*7);
      }
    });
    

    Just remeber to press the btn on the puck if you want to send some new code to the puck

  • in Puck.js
    Avatar for JackJamesHoward

    How can I detect once a connection has estabilished then run a LoopbackA.setConsole().
    I thinking it should automatically switch to LoopbackA.setConsole() then press the button on the puck to return to Bluetooth.setConsole(). I tried the following but it didn't work and I'm assuming it has something to do with switching to LoopbackA.setConsole() before a Bluetooth connection has been established.

    LoopbackA.setConsole(1);
    
    setWatch(function() {
      Bluetooth.setConsole();
    }, BTN, {repeat:true, edge:"rising", debounce:50});
    
    
    Bluetooth.on('data', function(d) { 
      if (d[0]=="!" && d[1]=="B") {
        var b = d.substr(2,2);
        if (b[0]=="1") LED1.write(0|b[1]);
        if (b[0]=="2") LED2.write(0|b[1]);
        if (b[0]=="3") LED3.write(0|b[1]);
      }
    });
    
  • in Puck.js
    Avatar for JackJamesHoward

    I get it now thanks @Gordon and sorry @Wilberforce you were correct.
    Gordon you're correct, copy and pasting does allow it to be sent as one packet.

  • in Puck.js
    Avatar for JackJamesHoward

    I can't do that because the puck will go back to being on Bluetooth instead of being in LoopbackA.

  • in Puck.js
    Avatar for JackJamesHoward

    Excellent explanation! Thank you for explaining the LoopBack to me, I was really scratching my head over how to stop the JS interpreter intercepting incoming data.

    It works really well with the app, however, I tried to use the WebIDE to pass a command string instead of using the app.
    When I press the button on the puck to activate the LoopBackA the WebIDE console locks up, the console logs -> LookbackA then it does not let me type anymore.

  • in Puck.js
    Avatar for JackJamesHoward

    The adafruit Bluefruit has a control pad the sends strings such as: !B41CRC
    I want to parse this into its component parts such as: [‘!’] [‘B’] [‘4’] [‘1’] [CRC]
    I think I can do this, but I don't know how to set a watch event that actually parses the string once it's received.
    It is not like the bluefruit app calls a function parse(!B41CRC). How do I watch for incoming data then do something with it?

Actions