Let's Make Robots!

Making Smart robot

Hi all,

My plans are as follow: I want to make my RC car into fully automated version.

Top view of car: http://i1265.photobucket.com/albums/jj519/soni991/RC%20Car/IMG_6682.jpg

Front view of car: http://i1265.photobucket.com/albums/jj519/soni991/RC%20Car/IMG_6683.jpg

Back view of car: http://i1265.photobucket.com/albums/jj519/soni991/RC%20Car/IMG_6684.jpg

Bottom view of car: http://i1265.photobucket.com/albums/jj519/soni991/RC%20Car/IMG_6685.jpg

The function involves (I give it as Version 1.0)

1) Steer itself throughout the house without bumping into any object. 

2) when power goes down then take itself to the powerport for charging. also it should check the battery power charge if it is sufficient and not overcharge the battery.

3) Goes on sleepmode after every half an hr of operation and then powerbackon after 1 hr ( that is changeable) .

these 3 basic function i need follow. 

I have RC car with 2WD. The steering wheels in front are of angular movement(it moves only to certain angle) : http://i1265.photobucket.com/albums/jj519/soni991/RC%20Car/IMG_6672.jpg

What gadgets i have available :

Picture: http://i1265.photobucket.com/albums/jj519/soni991/RC%20Car/IMG_6689.jpg


1) MCU = Mega 2560.(not in picture)

2) HC-SR04 1pc

3) US-100 1pc

4) SD memmory card using SPI protocol 2Pcs

5)TCRT5000 2PC

6) Microphone 1pc

7) Light Sensor 2pc

8) Audio amplifier 1pc

9) Accelrometer 1pc 

10) Bluetooth 1pcs

11) USD to TTL 2pc

12) NRF 24L01 3pc

13) 10Pin to 6pin  AVRisp 2Pcs

14) logo sensor 1pc

15) CP 2102 USB to TTL 1pc (not in picture)

16) lot of jumper wires and solderless board. not in picture

17) HC-SR501.

More parts are coming so i would update those list.

So I am good to go with parts, how to start building smart robot with clean code.

Please can anyone tell me how do i configure the steering wheel of this car on arduino? i have put all the pics here: http://s1265.photobucket.com/albums/jj519/soni991/RC%20Car/ 

any one suggest any new parts please let me know so i can purchase it and use on this project.

1) First thing i need is suggestion about what parts i should include for the basic function in Version 1.

2) Second the Programing Code written from scratch with everyone contribution.

Hope i can have feedback from taleted people online.






Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Yeah that is correct ! i am not sure if D2 was really required there! simply the (P2,0 ) could have done the job of switching the motor OFF upon max angle. my issue after making the turn signal then the steering need come back to center maybe after some millisecond or a second. what can be that command 



these are the schematic of circuit which i need use for detection of the angle. i am currently using 3 wires out of it. the white one i am not using. The brown is connected to grd and the yellow and blue is sensor input which detect the 0 upon contact. i think the white wire is the one used to bring the weel to center. CTC also thinks the same so i would try in evening.

I've noticed that you tend to post pictures when describing parts. Pictures are very useful, but links to the specifications, a datasheet, or where you bought the part from are generally more helpful.

Please describe your error (compiling, functioning ?) if you want help.

To detect whether your robot is running low on battery, connect a voltmeter chip across the battery leads and read the value to the microcontroller. When it drops below a certain threshold, it will know to charge up somewhere :)




int contactA;

int contactB;

int contactC;

int contactD;





void setup()








  digitalWrite(2,HIGH); //<-- this turns the internal pull-up on

  digitalWrite(3,HIGH); //<-- this turns the internal pull-up on

  digitalWrite(4,HIGH); //<-- this turns the internal pull-up on

  digitalWrite(5,HIGH); //<-- this turns the internal pull-up on









void loop()










  Serial.print("  ");


  Serial.print("  ");


  Serial.print("  ");









int inputState;


void setup()




  digitalWrite(2,HIGH); //<-- this turns the internal pull-up on




void loop()



  if (inputState==0)




  if (inputState==1)





Alright, when we got your motors going, our goal was just to get the motors moving, get you started and check if you hardware was working. In doing that, we ran into a couple snags (i.e. learning the digitalWrite command and For-loops). Now that you are up and running, it is time to go back a bit and start learning code.

Basically, you want "code to read a sensor and let your robot drive around automously". You are not going to find it. You may find some code you can modify, but you will need to know A) what to change B) where to find it in the code and C) how to change it. The bottom line is that you are going to have to learn some code.

Now, the over-all big-picture of robotics is to take something complicated and break it into very small steps. We can do the same thing when learning how to code. Instead of trying to jump ahead to a fully autonomous robot, you should spend some time figuring out each sub-section of code.

Here's what I would do:

Start with 2 things, a servo and a HC-SR04.

  • Figure out how to make your servo move to a certain position
  • Figure out For-loops and how to move a servo a little each step in a back-and-forth "sweep"
  • Find some sample code for you HC-SR04 and test your sensor using the serial monitor. Also, make note of the numbers you are getting and how they relate to the distance of an object to the front of your sensor
  • Add a "check sensor" routine to your for-loop so you take a reading each time the servo takes a "step" through its sweep

At this point, you should have a pretty good idea of the basics of code. 

Lemme know if you have any questions.

Hi i want to add new feature of Detection via sensors.


The Sensors i had are 

1) Mini motor speed sensor 2 pcs

2) Ultrasonic sensor 2 pcs (HC-SR04 1pc & US-100 1pc)

3) Accelrometer 1pc

4) 3-axial Gyroscope (GY-521 MPU-6050) ipc

5) Light Sensor 2pc

6) logo sensor 1pc

7) Infrared Sensors (HC-SR501)

8) reflective Infrared sensors (TCRT5000 2PC)


Which one to use has good effect in detection and prevention for the nearby surrounding.

If can i use multiple sensors at same time to give more detail information about surroundings.

please leave your comment.

Well after little big of google and support on shoutbox and some lookup of codes of existing projects i came up with function using ultrasonic sensors for detection.

but as at moment my front wheel are not connected to motor controller neither i am writing any command for it. the code looks like as below.


#include <Ultrasonic.h>

#define TRIGGER_PIN  13

#define ECHO_PIN     12

#define TRIGGER  9

#define ECHO     8


Ultrasonic front(TRIGGER_PIN, ECHO_PIN);

Ultrasonic rear(TRIGGER, ECHO);

int P1 = 6;                      

int D1 = 7;                        

void setup() 


pinMode(D1, OUTPUT); 

pinMode(P1, OUTPUT);



void loop()


//front distance calculation

float cmMsec, inMsec;

long microsec = front.timing();


cmMsec = front.convert(microsec, Ultrasonic::CM);


Serial.print(", CM: ");



// rear distance calculation

float RcmMsec, RinMsec;

long Rmicrosec = rear.timing();


RcmMsec = rear.convert(Rmicrosec, Ultrasonic::CM);


Serial.print(", RCM: ");



/* this is for the movement upon detection logic*/

if (cmMsec >= 45) // if ultra sonic see distance greater then 25cm go forward


int value(70);


analogWrite(P1, value);


if (cmMsec < 25) // if the Front Ultrasonic detects distance less then 10cm then Brakes.



if (RcmMsec > 25) // if the back distance is more then 25cm then go back


int value(70);



analogWrite(P1, value);






For object detection you can use a few of those...

2) HC-SR04s are easy to use, nice general rangefinders. Like all ultrasonic sensors they don't like plush upholstery and certain fabrics. The US-100 might be nice with it's serial capabilities.

5) Light sensors are good for keeping bots from being under objects and for adding phototropic/photophobic behaviors.

6) Does sensor this find Nike swooshes and Gucci brandings? ;)

7) Looks like a standard PIR sensor. Good for detecting motion but not good for localizing the object in motion.

8) Small and simple analog sensor but very short range. Useful for edge detection or maybe line following.