Instructables

Carduino- A simple Arduino robotics platform with its own library

FeaturedContest Winner
Picture of Carduino- A simple Arduino robotics platform with its own library
IMG_0214.JPG
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)

 
Remove these adsRemove these ads by Signing Up
katanahikari6 months ago

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.

12203madman8 months ago
does arduino uno r3 work
gadgetnerd337310 months ago
my brother would approve of your username, he has the same problem with his name.
jakjakjak1 year ago
Very nice tutorial. Simple and to-the-point. Thanks!
alecnotalex (author)  jakjakjak1 year ago
Glad I could help!
Keshern2 years ago
(removed by author or community request)
Keshern Keshern2 years ago
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()
alecnotalex (author)  Keshern2 years ago
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?
Keshern2 years ago
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.
alecnotalex (author)  Keshern2 years ago
Yes, you could.
smaw512 years ago
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();
}
Higgs Boson2 years ago
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?
alecnotalex (author)  Higgs Boson2 years ago
Yes, it works just fine for me.
Interesting. Your motors must not have a very large current consumption then.
DerekK192 years ago
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
Kiteman2 years ago
(If you're going to glue your battery in place, best make sure it's rechargeable...?)
alecnotalex (author)  Kiteman2 years ago
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.
You can get clips for the terminals, and clips for the actual battery - I'm guessing most folk will go that way.

Since I have your attention, it would be nice to see a video of Carduino on the move...?
alecnotalex (author)  Kiteman2 years ago
Video is soon to be posted.
Cool.