CellBots control code


  1. jlivingstonsg

    jlivingstonsg New Member

    Hi

    I try to activate the 3:rd wheel on a lego mindstorm nxt robot by adjusting cellbots code in eclipse.
    It can be remote controlled from a webpage with keys
    index.html - cellbots - Using Cellphones as Robotic Control Platforms - Google Project Hosting
    with this javascript code.
    ------------------------------------------------
    function onKeyDown(evt) {
    if (evt.target == speakTxt ||
    evt.target == speakCombo) {
    if (evt.keyCode == keyCodes.ENTER) {
    sendAction('speak:' + speakTxt.value);
    }
    return true;
    }
    if (evt.keyCode == keyCodes.SPACE)
    sendAction('s');
    else if (evt.keyCode == keyCodes.ARROWUP && prevAction != 'f') {
    sendAction('f');
    } else if (evt.keyCode == keyCodes.ARROWDOWN && prevAction != 'b') {
    sendAction('b');
    } else if (evt.keyCode == keyCodes.ARROWRIGHT && prevAction != 'r') {
    sendAction('r');
    } else if (evt.keyCode == keyCodes.ARROWLEFT && prevAction != 'l') {
    sendAction('l');
    }
    }
    ----------------------------------------------------
    I try to change the code from this
    else if (evt.keyCode == keyCodes.ARROWUP && prevAction != 'f')
    to this
    else if (evt.keyCode == keyCodes.ARROWUP && prevAction != 'hl')
    and it activate the 3:rd wheel but it have a very low speed.
    How am I to write (optional argument) with the 'hl' to set a new wheel speed?

    I have tried (optional argument) like 'hl' + '8' or 'hl' + 8 or 'hl+8' but no response.

    Does anybody know how to write an (optional argument) to 'hl' ???
    Here is the code info about how to use the javascript code and its argument.

    LegoNXTDocumentation.wiki - cellbots - Using Cellphones as Robotic Control Platforms - Google Project Hosting
    -------------------------------------------------
    || command {required argument} (optional argument) || argument description || argument description || notes ||
    || f (speed) || speed: '0' to '9' || || drive forward ||
    || b (speed) || speed: '0' to '9' || || drive backward ||
    || l (speed) || speed: '0' to '9' || || turn left ||
    || r (speed) ||speed: '0' to '9' || || turn right ||
    || s || || || stop the wheels||
    || '0' through '9' || a single number, '0'-'9' || || sets the default speed for f/b/l/r ||
    || w {velocity} {velocity} || velocity: "-100" to "100" || || set wheel velocities ||
    || hl (speed) || speed: '0' to '9' || || turn the third motor left (arbitrary) ||
    || hr (speed) || speed: '0' to '9' || || turn the third motor right ||
    || df {distance} (speed) || distance: in degrees. || speed: '0' to '9' || drive forward a set distance ||
    || db {distance} (speed) || distance: in degrees. || speed: '0' to '9' || drive backward a set distance ||
    || dl {distance} (speed) || distance: in degrees. || speed: '0' to '9' || turn left a set distance ||
    || dr {distance} (speed) || distance: in degrees. || speed: '0' to '9' || turn right a set distance ||
    || hdl {distance} (speed) || distance: in degrees. || speed: '0' to '9' || turn head a set distance left ||
    || hdr {distance} (speed) || distance: in degrees. || speed: '0' to '9' || turn head a set distance right ||
    || demoLineFollow || || || Follows a line ||
    || demoFindWall (distance) || distance: in cm, distance from wall to stop || || Drives until within (distance) or 20 cm of a wall ||
    || demoStop || || || Stops any in progress demo behaviors ||

    Advertisement
    :
Loading...
Similar Threads
  1. ford351w
    Replies:
    2
    Views:
    5,144
  2. junny6969
    Replies:
    1
    Views:
    490
  3. tdave
    Replies:
    1
    Views:
    3,579
  4. w_bovine
    Replies:
    7
    Views:
    4,081

Share This Page