Keyboard Controlled Boe-Bot Robot
Andy Lindsay (Parallax)
Posts: 1,919
This example code makes it easy to control your Boe-Bot while it is connected to a PC via the Programming cable. After you run the code, use these keys to control the Boe-Bot:
8 = forward
2 = backward
4 = rotate left
6 = rotate right
5 = stay still
There's no need to hold the key down, just press/release it once (sometimes twice if the BASIC Stamp misses the first character because it's busy sending pulses to the servos).
8 = forward
2 = backward
4 = rotate left
6 = rotate right
5 = stay still
There's no need to hold the key down, just press/release it once (sometimes twice if the BASIC Stamp misses the first character because it's busy sending pulses to the servos).
' {$STAMP BS2} ' {$PBASIC 2.5} pulse VAR Word maneuver VAR Word FREQOUT 4, 2000, 3000 DEBUG "8 = forward", CR, "2 = backward", CR, "4 = rotate left", CR, "6 = rotate right", CR, "5 = stay still" DO SERIN 16, 84, 20, Timeout, [maneuver] Timeout: GOSUB Go LOOP Go: LOOKDOWN maneuver, ["5", "8", "2", "4", "6"], maneuver LOOKUP maneuver, [750, 850, 650, 650, 850], pulse PULSOUT 13, pulse LOOKUP maneuver, [750, 650, 850, 650, 850], pulse PULSOUT 12, pulse RETURN
Comments
Thanks a lot.
Product page:
http://www.parallax.com/tabid/768/ProductID/563/Default.aspx
Downloads & Resources
http://www.parallax.com/tabid/176/ProductID/92/Default.aspx
http://www.parallax.com/tabid/755/ProductID/248/Default.aspx
The simplest way to add keyboard control of the turret servo would be to duplicate elements of the wheel control servo code for a third turret servo. For example, you could start by adding a couple of variables for turret character and turret pulse control. Something like this:
turretChar VAR Byte
turretPulse VAR Word
Then, add a second SERIN command to get a second character for turret direction to the DO...LOOP:
SERIN 16, 84, 20, TimeoutTurret, [turretChar]
TimeoutTurret:
Inside the Go subroutine, you'd probably want to add something like this (assuming turret servo is connected to P14):
LOOKDOWN turretChar, ["4", "7", "8", "9", "6"], turretChar
LOOKUP turretChar, [1100, 925, 750, 550, 350], turretPulse
PULSOUT 14, turretPulse
For more information on standard servo control, download "What's a Microcontroller? v3.0 (.pdf)" from the www.parallax.com/go/WAM resource page, and check out Chapter 4.
For more information on Boe-Bot continuous rotation servo control, download "Robotics with the Boe-Bot Text v3.0 (.pdf)" from the www.parallax.com/go/Boe-Bot resource page and check Chapter 2, Activity #4, #6, and Chapter 4.
I'm wondering if a microphone on a PropBot could hear a note from the piano and react to the pitch. What a set of possibilities for integration of music and motion. I'll start digging through the Objects Exchange. Remember the video of the Hokey Pokey Toddler Dance Team from five years ago?
If you'd like to be able to do more, I'd recommend going to www.parallax.com/go/WAM and downloading the What's a Microcontroller PDF. Each chapter has a few activities, and each activity takes about 15 minutes to work through. You can skip the 5th activity in chapters 2 and 3. By the time you are through with Chapter 4, you'll be able to do it on your own, and you'll know all about the "fancy new code stuff" and lots more.
I'm sorry I'm being so confusing. I'm trying to use a snap rover base from elenco's snap circuits that has the regular small motors found in rc cars. I'm trying to control that from a laptop that is on board the snap rover. I am controlling it using logmein so it is as if I am sitting at the laptop controlling it. I hope this makes sense.
I am connecting the basic stamp homework board to the motor inputs on the snap rover. This is the snap rover. http://www.amazon.com/Elenco-SCROV-10-Snap-Circuits-Rover/dp/B000GG7XXK. I'm just using the yellow base with the motors in it.
It looks to me like you'll need to control the U8 motor control block with I/O pins and series resistors. I'd recommend this circuit:
Homework.......Series................U8 Motor
Board..............Resistor.............Control Block
P15
R=1k
LF
P14
R=1k
LB
P13
R=1k
RF
P12
R=1k
RB
With that circuit, this code should work. You might need to reduce the series resistor values from R=1k to R=470, but try it with 1k first.
Is "this" in "Does this work" refer to the program in the top post? If so, then the exact program won't work with the ActivityBot but the AB can do this sort of stuff much easier than the BOE-Bot could. Do you want to control the AB by sending commands over the USB cable?
Check:
http://learn.parallax.com/activitybot
for the current ActivityBot-based projects. The projects are updated regularly, so check back often. Drop them a line if you see something for the BS2 BOE-Bot, and are interested in doing the same with the ActivityBot.
Duane yes, can you help me understand how to control ActivityBot on macbook connected via USB?
The trick to this code is disconnecting the default serial terminal connection for print and scan calls and replacing it with one that runs in another cog. Why? Because the fdserial library has an rxTime function that only waits for a certain amount of time, so the code won't get stuck waiting for characters. Although not critical here, there are lots of cases where the ActivityBot will want to also scan for sensors.
There are lots of applications which can benefit from monitoring the serial line without blocking the flow of the program.
Thank you for the example.
Thank you again!