Most recent activity
-
- 3 comments
- 1,713 views
-
Hi
I have a little test script running fone when connected to USB:
var s = require("servo").connect(B13); var curBuff = ""; Serial1.on('data', function (data) { try{ if (data==","){ s.move(parseFloat(curBuff)); curBuff = ""; } else{ curBuff += data; } } catch(err){ } }); // keep track of the next LED var next_LED = 1; // keep track of the ID, see later var timeout_ID; function swap() { // remove the timeout to turn of all LEDs when the user pressed the button if (timeout_ID !== undefined) { clearTimeout(timeout_ID); } // determine which LED to turn on/off switch(next_LED) { case 1: LED3.write(1); LED1.write(0); s.move(0.5); break; case 2: LED2.write(1); LED3.write(0); s.move(0); break; case 3: LED1.write(1); LED2.write(0); s.move(1); break; } // determine the next LED to turn on next_LED = Math.wrap(next_LED, 3) + 1; // prepare a timeout to turn off all LEDs after a while // we capture the ID here, so that we can use it in a next call to this function timeout_ID = setTimeout(function () { LED1.write(0); LED2.write(0); LED3.write(0); timeout_ID = undefined; }, 5000); } setWatch(swap, BTN1, {repeat:true, edge:"rising"});
If I send messages to the bluetooth connection from an app on my phone, first a string of a float (e.g. '0.1') then post another BT message containing just a comma ',' the servo moves.
I can disconnect from the WebIDE. It still works.
However! If I unplug the USB, I get a BT message back from the board to my phone:
'Console Moved from USB'
Now it fails to work. I send it the float, it echos it back. I send the comma, its sends error:
"Uncaught SyntaxError: Got ',' expected EOF at line 1 col 1
,
^"Any help appreciated. :)
Phil -
-
Hi.
I was assuming that if I removed the board from being connected to my laptop, then powered it back up via a battery, that it would be able to run the code I send to it from the IDE. However when I power back on, nothing doing.
I have a microSD card inserted, but I guess I'missing something obvious.
Please help a n00b.
Cheers
Phil
Oh I love the idea of sending commands as script to execute :)
Yep that got it working.
Many thanks!