Carduino- a Simple Arduino Robotics Platform With Its Own Library

36K11224

Intro: Carduino- a Simple Arduino Robotics Platform With Its Own Library

This is, as the title says, an Arduino-based robotics platform, with its own library. The "standard" model comes with two back motors, two omni-wheels in the front, and a distance sensor mounted on the front. It also has breadboard space on top for adding whatever you want. It is intended to be autonomous, but one can make it remote controlled if they really want to. This instructable will teach how to build it, how to use the library, and it will include some sample projects too.

What is the library?
The library will make controlling your Carduino a little easier. This project is intended for those with little programming experience, and just want to get started with simple robotics. You don't even need to know how to use a motor shield to use it. It's as simple as saying "turn right for 1 second" or "go forward for 3 seconds, and then speed up." The library also contains example code to help you get started.

What exactly is in the library?
Step 13 contains all the important information regarding the library, and all example projects.

Why would you ever want a wooden chassis, and is it fine if I build mine differently?
Of course you can build yours differently! The library will work almost no matter what you do, so you can change the design to whatever you'd like. The only reason why I used a wooden chassis was because it was the only material for this I had, so you can feel free to use whatever else you'd like.

What can this robot do?
It can do just about anything. Even just with the parts on the standard model, there is infinite possibilities. With Arduino and the Carduino library, programming it is incredibly easy, and it can do anything you can imagine. The extra breadboard space allows you to add a variety of sensors, to make it do just what you want.

How much does it cost?
Roughly one hundred dollars, if you're starting out with nothing.  I had almost all the parts before I started, so the price was only about thirty dollars for me. Most all of the parts are very common, and you should have many of them.

Here is a terrible video of it in action:
(due to some issues with the distance sensor, I could not get object-avoidance in the video, but, I assure you, it works)

STEP 1: Supplies

1 Arduino Uno http://www.sparkfun.com/products/11021
1 Breadboard http://www.sparkfun.com/products/9567
1 Arduino and breadboard holder http://www.sparkfun.com/products/10059
1 Sharp long range proximity sensor http://www.sparkfun.com/products/8958
2 Micro metal gear motors http://www.sparkfun.com/products/8910
1 Pair of 49x19mm wheels http://www.sparkfun.com/products/8899
1 Pair of motor mounting brackets http://www.sparkfun.com/products/8896
1 Pair of omni-wheels http://www.sparkfun.com/products/320
1 Arduino motor shield http://www.amazon.com/gp/product/B007BHKRVW/ref=oh_details_o00_s00_i00
1 15x10.75cm piece of wood      (check size with the Arduino and breadboard holder)
12 #4 x 3/4" Wood screws
1 9v battery
Some Wire

STEP 2: Set Up Various Things

Here some things you need to do before you begin:
Cut wood to correct size
Make Omni-wheels (instructions came with them)
Attach wheels to motors
Insert Arduino and breadboard into the holder.

STEP 3: Mount Omni-wheels

Position both of them 0.5" from the front, and 0.5" from either side. Mark holes for mounting, then drill them. Use your #4 x 3/4" wood screws to mount them.

STEP 4: Mount Motors

This step is fairly easy. All you do is insert the motors into the mounting brackets, and super glue the brackets onto the corners. You may want to have already solder wires to them though, I ended up needing to remove the motors to solder later on.

STEP 5: Mount Arduino & Breadboard

You should begin by centering the Arduino and breadboard holder on the chassis. Remember that the breadboard should be in the front. Next, mark holes to drill. Then Arduino and breadboard holder already has to holes in the center, you should use those. After you marked the holes, you need to drill them, and mount the holder using #4 x 3/4" wood screws.

STEP 6: Mount Proximity Sensor

This should be fairly straightforward. Just mark holes, and drill. You should be using the mounting holes on either side of the sensor. It doesn't need to be centered on the front, but if you want it to be, it should be about 1.5" from either side. Use #4 x 3/4" wood screws, yet again. MAKE SURE that when you do this the JST is on top.

Insert your JST wires into the sensor.
Now, put the red wire in the positive thingy in your breadboard, the black wire in the negative, and the yellow can go anywhere in the breadboard.

STEP 7: Attach Motor Shield

You should know how to do this, just line it up and stack it onto your Arduino.

STEP 8: Solder to Motors

Just solder some wires to you motors. Make sure to remember which are positive, and which are negative.

STEP 9: Wire Motors to Motor Shield

This is much more complicated than you would imagine.

Wire positive on the right motor to the negative terminal for motor A.
Wire negative on the right motor to the positive terminal for motor A.

Wire positive on the left motor to the positive terminal for motor B.
Wire negative on the left motor to the negative terminal for motor B.

If anyone believes these are wrong, please notify me. I am quite sure that I'm correct, but there is a chance that I lost track of which wire is which.

STEP 10: Wire Breadboard and Sensor

Connect 5v to the positive column thingy in the breadboard. Connect GND to the negative thingy. Connect the yellow sensor thing to analog pin 2.

STEP 11: Attach Battery

Just super glue a 9v battery to the back of your Carduino. Then, attach the positive and negative wires (either soldered or with battery clip) to the positive and negative terminals on your Carduino.

STEP 12: You're Done Building!

You have finished building the "standard" model of the Carduino. The great thing about the Carduino is any Carduino can run any Carduino code. All of the examples that come with the library will run on your Carduino, without any modifications. Next, I will explain the library, and exactly what's included.

STEP 13: The Library

To install the library:
Download Carduino.zip at the bottom of the step. Find /arduino-1.0/libraries. Extract the library to that location. Now, to use it, open up the Arduino IDE, go to sketch -> import library -> Carduino.

Here are the functions in the library:
void mycarduino.begin ()
Starts up the Carduino. Call in setup ().

void mycarduino.goforward(float seconds, int speed)
This function moves the Carduino forward for the specified time and speed. The speed should be any number from 1 to 1023, with 1023 being the fastest.

void mycarduino.goback(float seconds, int speed)
The same as the function above, only backward.

void mycarduino.turnright(int time)
Turns the Carduino right for the specified time, in milliseconds.

void mycarduino.turnleft(int time)
Turns the Carduino left for the specified time, in milliseconds.

int mycarduino.proximity()
Returns the reading of the proximity sensor, in centimeters.

Examples:
Go to      File -> Examples -> Carduino -> [name of your choice]

Blink- Drives the Carduino forward for a second, stops for a second, and repeats. This should be your first "hello world" program.

Object Avoid- Drives forward constantly, until an object comes within 25 centimeters. Then, it chooses a direction (left or right, chosen randomly) and it turns that distance for a random amount of time, between 800 and 2300 milliseconds.

Cautious Driving- Works like object avoid, but if it notices something within 40 centimeters, it slows down.

Spiral- Drives in an outward spiral.

STEP 14: Enjoy

You have now finished everything! If you have any questions, comments, or angry rants, you can feel free to post them in the comments, and I'll try to get back to you. Have fun, and happy Carduino-ing!

23 Comments

very nice' but can we use a ultrasonic sensor in place of the SHARP sensor????????????

I'm having trouble installing the library.

I downloaded the zip file and imported the library, but when I put it in the sketch it only shows the .h file and gives me the error message:

core.a(main.cpp.o): In function `main':
C:\Program Files (x86)\Arduino\hardware\arduino\cores\ard... undefined reference to `setup'
C:\Program Files (x86)\Arduino\hardware\arduino\cores\ard... undefined reference to `loop'

The four "example" files show up in the sketchbook, but each opens in a new window. They individually verify, but when copy/pasting them together I get error messages.

I can't seem to import the .cpp file at all, and when I try to drag and drop it I get the same error message.

my brother would approve of your username, he has the same problem with his name.
Very nice tutorial. Simple and to-the-point. Thanks!
I take you code, but theres an error.

I put this on the Arduinoprogram:

void mycarduino.begin () Call in setup ().

void mycarduino.goforward(float 4, int 12)

void mycarduino.goback(float 4, int 12)

void mycarduino.turnright(int 2)

void mycarduino.turnleft(int 2)

int mycarduino.proximity()
Have you tried running any of the example programs from File -> Examples -> Carduino? Make sure that when you call a function, you just call it with the numbers like "goforward(4, 12)" not "goforward(float 4, int 12).

What exactly did the error say?
Hello Guys!

Could i use Motorshields from this Collection?

http://www.amazon.de/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=Arduino+Motor+Shield+R3


?? I cannot buy the Motorshield R3 on Amazon.US, because i dont have VISA or a Mastercard.
add a bluetooth slave to this to make it even better! cheap remote control car your android phone! I need to spend more time getting the ultrasonic sensor to work on my code.
Use BlueTerm from google play to control it.

#include //motor shield
#include //Software Serial Port
#include // android link bluetooth
#define RxD 6 // BT com these are backwards on the shield
#define TxD 2 //BT com backwards on BT shield, jumpers
#define trigPin A4 //sensor trig to analog 4
#define echoPin A5 //sensor echo to analog 5
#define objLED A3 // set obsticle indicator led to analog 3

AF_DCMotor lmotor(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor rmotor(1, MOTOR12_64KHZ); // sets the left motor to port 1



SoftwareSerial blueToothSerial(RxD,TxD);

void setup()
{
Serial.begin(38400); // set up Serial library at 9600 bps
pinMode(RxD, INPUT); //set pin 6 to BT in
pinMode(TxD, OUTPUT); //set pin 2 to BT out
pinMode(trigPin, OUTPUT); //sets ultrasonic sensor
pinMode(echoPin, INPUT);
pinMode(objLED, OUTPUT);
setupBlueToothConnection(); //
rmotor.setSpeed(200); // set the RIGHT motot speed to 220 from 0 to 255
lmotor.setSpeed(200); // set the Left motor speed to 200 from 0 to 255
}


void loop()
{
//get distance before collision
float duration, distance;
digitalWrite(trigPin, HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
Serial.println(distance);
//end distance

//recieve and execute comands via bluetooth
char recvChar;

if(blueToothSerial.available())//check if there's any data sent from the remote bluetooth shield
{
recvChar = blueToothSerial.read();
switch(recvChar)
{
case 'w': //forward
blueToothSerial.println("forward");
rmotor.run(FORWARD);
lmotor.run(FORWARD);
if(distance <= 10 && distance >=1) // stop motor if distance is less than or equal to 10 cm
{
avoidObject();
}
break;


case 's': //backwards
blueToothSerial.println("reverse");
rmotor.run(BACKWARD);
lmotor.run(BACKWARD);
break;

case 'e': // stop
blueToothSerial.println("stopping");
rmotor.run(RELEASE);
lmotor.run(RELEASE);
break;

case 'a': // turn left
blueToothSerial.println("turning left");
lmotor.run(FORWARD);
rmotor.run(BACKWARD);
break;

case 'd': //turn right
blueToothSerial.println("turning right");
lmotor.run(BACKWARD);
rmotor.run(FORWARD);
break;

}//end switch case



} // end BT com
} // end loop

void avoidObject()
{

digitalWrite(objLED,HIGH);
rmotor.run(RELEASE);
lmotor.run(RELEASE);
//delay(20);
rmotor.run(BACKWARD);
lmotor.run(BACKWARD);
delay(100);
}

void setupBlueToothConnection()
{
blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
blueToothSerial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave"
blueToothSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
blueToothSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
delay(2000); // This delay is required.
blueToothSerial.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
Serial.println("The slave bluetooth is inquirable!");
delay(2000); // This delay is required.
blueToothSerial.flush();
}
The motor shield you are using has a relativly high current demand. One standard nine volt battery cannot supply that current. With my shield, I was needing power supplys with at leaste 800ma, and settled on using a 1600mah battery for all projects using that shield. Did the 9v battery actually drive the shield?
Yes, it works just fine for me.
Interesting. Your motors must not have a very large current consumption then.
Great tutorial, and just at the right time for me. My next project is to be a robot just like this. Thanks for the helping hand
(If you're going to glue your battery in place, best make sure it's rechargeable...?)
I didn't think that through very much, thanks for pointing that out. I think even if they were rechargeable, it would be difficult to recharge them while they're glued on. I suppose velcro, or some sort of holder would the best way to solve that problem.
More Comments