BBC Turtle Clone?

You would just send it those kinds of commands from the serial monitor, and have the robot receive and save them, then run them when it got a "go" command?
Looks like you have
Pen Down
Pen Up
Left Turn degrees
Right Turn degrees
Forward distance
would there be Reverse distance?
Home - not sure what that does.

That would be straightforward to implement in Arduino code, maybe something like this, flesh out the motor command parts

if (Serial.available()>1){ // start of message?
iC[0] = Serial.read(); // iC[] = incoming Command array
iC[1] = Serial.read();

// pen up or down
   if (iC[0] == 'P'){
       if (iC[1] == 'D'){
       valid = 1; // good command received
       // command motor/servo/stepper whatever to put pen down
       }
      if (iC[1] == 'U'){
       valid = 1; // good command received
      // command motor/servo/stepper whatever to pick pen up
       }
   }
// left turn
  if (iC[0] =='L' and iC[1] == 'T'){
  // wait for degrees to come in, must be 3 digits
   while (Serial.available()<3){
   ic[2] = Serial.read() - 0x48; // read ASCII and convert to a number
   ic[3] = Serial.read() - 0x48; // read ASCII and convert to a number
   ic[4] = Serial.read() - 0x48; // read ASCII and convert to a number
   degrees = ic[2]*100 + ic[3]*10 + ic[4]; // convert to 0 to a number
    valid = 1; // good command received
   // send motor command to turn/spin left the number of degrees commanded
   }
// right turn
  if (iC[0] =='R' and iC[1] == 'T'){
  // wait for degrees to come in, must be 3 digits
   while (Serial.available()<3){
   ic[2] = Serial.read() - 0x48; // read ASCII and convert to a number
   ic[3] = Serial.read() - 0x48; // read ASCII and convert to a number
   ic[4] = Serial.read() - 0x48; // read ASCII and convert to a number
   degrees = ic[2]*100 + ic[3]*10 + ic[4]; // convert to 0 to a number
    valid = 1; // good command received
   // send motor command to turn/spin right the number of degrees commanded
   }
// forward
  if (iC[0] =='F' and iC[1] == 'D'){
  // wait for distance to come in, must be 3 digits
   while (Serial.available()<3){
   ic[2] = Serial.read() - 0x48; // read ASCII and convert to a number
   ic[3] = Serial.read() - 0x48; // read ASCII and convert to a number
   ic[4] = Serial.read() - 0x48; // read ASCII and convert to a number
   distance = ic[2]*100 + ic[3]*10 + ic[4]; // convert to a distance
   valid = 1; // good command received
   // send motor command to go forward some distance
   }
// backward
  if (iC[0] =='B' and iC[1] == 'K'){
  // wait for distance to come in, must be 3 digits
   while (Serial.available()<3){
   ic[2] = Serial.read() - 0x48; // read ASCII and convert to a number
   ic[3] = Serial.read() - 0x48; // read ASCII and convert to a number
   ic[4] = Serial.read() - 0x48; // read ASCII and convert to a number
   distance = ic[2]*100 + ic[3]*10 + ic[4]; // convert to a distance
    valid = 1; // good command received
   // send motor command to go backward some distance
   }
// Home
  if (iC[0] =='H' and iC[1] == 'M'){
   valid = 1; // good command received
   // send motor command to go do whatever "home" means
   }
if (valid == 0){
Serial.print("invalid command received ");
Serial.print(ic[0]);
Serial.println(ic[1]);
}
valid = 0; // clear flag for next pass
} // end Serial.available check

@CrossRoads
For someone who claims not to be good at programming that is a really nice piece of code.
Best regards
Jantje

Thanks Jantje. :slight_smile:
I don't find simple manipulation of minimal serial data to be difficult. 5 bytes, not many options, not much there.
Now, if the degrees or distance was allowed to be 1,2, or 3 digits, that would certainly complicate things 8)

I do find following other people's uncommented cryptic C/C++ code to be difficult to follow. I just glaze over looking at it sometimes.

I was thinking using switch:case would run faster, without have 5 or 6 sets of if:then statements to go thru.
I don't know how to define cases based on two array elements tho.
Somehow make a variable
command = iC[0] + ic[1];
then use that for the cases.
Probably simple, I've just never done that:

switch(command){
case 'PD':
// 
break;
case 'PU':
// 
break;
//etc.
}

rofl
many programmers don't make a distinction between char ' and char array " when defining constants. When you do I see that as an indication of quality. Moreover the code is readable and well documented. It shows knowledge of arrays and string to value conversion.

Switch Case does not support string comparison. If you want to do something with 2 chars you would have to do something like 'a'*FF+'b'.
Not a pretty sight. So if then else is the best option I know.

Now, if the degrees or distance was allowed to be 1,2, or 3 digits,

not really just change

degrees = ic[2]*100 + ic[3]*10 + ic[4]; // convert to 0 to a number

to something like:

degrees=0;
for(int curChar=2;curChar<numsChar;curChar++) degrees=degrees*10+ic[curChar];

Best regards
Jantje

for(int curChar=2;curChar<numsChar;curChar++) degrees=degrees*10+ic[curChar];

See, now it gets messy. Have to figure out to stop waiting for more digits to come in;
numsChar = sizeof[ic] or whatever that syntax is;
looks like something else is needed to catch the 100's place.
That kind of variability is hard to write for.
Writing for fixed constraints is much easier.

Switch Case does not support string comparison

See, that would have been handy to have!
Now, one would have to convert each command: PU, PD, RT, LT, FD, BK, HM into a number and then do switch:case on the number.
Or: change the command to make each one start with a unique letter and do switch:case on a single letter.
'U' P up pen
'D' P down pen
'R' T right turn
'L' T left turn
'F' D forward
'B' K backward
'H' M home
in which case, just single letter commands could be used, making things simpler still.

Hey

Thanks guys. This is the germ of an idea in my mind, but I very much appreciate the code examples. I'm very new to coding myself and agree about uncommented sketches. It took me days working about a very simple shift register example that was included with the library!

Still, I'll spend some time planning out the hardware.

That's awesome. I remember using LOGO back in grade school!

Hey, if it helps, or if anyone wants to play with it...I just found this -

  • an online LOGO emulator.

I just wasted about 30 mins playing around on it! XD

If you need a motor driver, you could check out these boards

http://www.ruggedcircuits.com/html/basic_motor_driver.html
http://www.ruggedcircuits.com/html/rugged_motor_driver.html
and the choices & chassis here

So I have been browsing around and researching my options. I think CrossRoads was correct about using the Pololu 3pi style robot for this project. For it to work just like the original Turtle, the pen will have to be dead centre and the robot will have to rotate exactly around that point. Ultimately I think I would enjoy designing the robot's chasis and specs. So I'm thinking about getting a kit robot to test ideas and learn what I need in the final design.

What do you guys think about these ultra-cheap kits from China:

http://www.ebay.co.uk/itm/171056734576 ?

I'm thinking for testing it will work out fine. Or should I double my money and go for something like this:

http://www.ebay.co.uk/itm/130936585418

Views welcome

Your call.
How expandable are they if you decide to make something more out of it?

How will you mount the pen dead center and have room to move it up & down if the control boards are there?
Maybe mount the control boards vertically instead of laying flat on the chassis?

The pen setup would have to be the first thing installed. Everything else would be built around it.

IntelliTom:
What do you guys think about these ultra-cheap kits from China:

http://www.ebay.co.uk/itm/171056734576 ?

I'm thinking for testing it will work out fine. Or should I double my money and go for something like this:

http://www.ebay.co.uk/itm/130936585418

Views welcome

The second one seems to have the wheels more 'centered' front-to-rear. Reminds me more of a Roomba....which does an amazing job of spinning in place. Would probably do a better job of keeping pen centered while turning.

My imagination dreamed up the following: a scorpion hexapod with a pen as a stinger.

Turtles have been done! Hexapods are the new black!!

I just read a thread like this: Bluetooth robotic dancer - Robotics - Arduino Forum

Just stumbled on this Arduino Robot Library tutorial —

Some interesting information being posted here.

I have an original BBC turtle robot in my shed and surprised how solidly it was built.

I have an arduino +motor shield but never sat down to use it.

It's a little late, and I'm not sure if you'll still be interested, but I too was keen to build a Turtle robot based on the Arduino for my kids. I've been building it for a while now and thought you might be interested - it's open source (or it will be when I put the designs online shortly) and pretty easy to build. It's WiFi based and battery powered. I've also built a Logo virtual machine that runs on the Arduino which lets you hook up commands to do whatever you want really.

The robot is here: http://mirobot.io

and the Logo VM is here: GitHub - bjpirt/LogoVM: A simple configurable LOGO based virtual machine for Arduino

Give me a shout if you're interested and I'll happily send across the designs (they'll be online in the next week or so anyway)

Cheers,
Ben