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

List:

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.

Getting rid of the for loop, and doing things sorta "manually", it will look something like this:

 

int E1 = 5;  

int M1 = 4; 

int E2 = 6;                      

int M2 = 7;                        

 

void setup() 

    pinMode(M1, OUTPUT);   

    pinMode(M2, OUTPUT); 

    pinMode(E1, OUTPUT);   

    pinMode(E2, OUTPUT); 

void loop()

  int value=255;  //use a scale of 0 - 255

 

    digitalWrite(M1,LOW);   // @Chris suggest for reverse movement

    digitalWrite(M2,LOW);   // @Chris suggest for reverse movement    

    analogWrite(E1, value);   //PWM Speed Control

    analogWrite(E2, value);   //PWM Speed Control

    delay(2000); 

   digitalWrite(M1,HIGH);   // @Chris suggest for reverse movement

    digitalWrite(M2,HIGH);   // @Chris suggest for reverse movement    

    analogWrite(E1, value);   //PWM Speed Control

    analogWrite(E2, value);   //PWM Speed Control

    delay(2000); 

}

With the existing code: i want to add the feature of moving ahead and reversing back to same location.

Please note the M2 is connected with the rear wheel and the M1 at moment is blank.

NOTE: (i am planing to add M1 in future just to steer upto certain angle rather then complete 360' turn of wheels. as posted above the steering picture it can move in certain angle only. Pic Here :  http://i1265.photobucket.com/albums/jj519/soni991/RC%20Car/IMG_6672.jpg )

Hi all,

The features for moving forward stop and then reverse back in loop were very hard for noob like me at first but with help of Chris and Birdmun the code looks very simple and understable.

 

/* my rear wheel wires are connected to the M1 port of the Motor controller.*/

int P1 = 6;  //these are the Pin name on the motor controller connected to the digital pin no 6 of Mega 2560.                

int D1 = 7; //these are the pin name on the motor controller  connected to the digital pin no 7 on mega 2560.

void setup(){  

pinMode(D1, OUTPUT); 

pinMode(P1, OUTPUT);

}

void loop(){

analogWrite(P1,0);   // this is to keep the motor off by 2 second @birdmun suggested 

delay(2000);

 

/* this is for the Forward movement as the D1 is set to HIGH*/  

{

    int value;  //used as speed scale for the motor

    for( value = 50; value <= 255; value+=20) // this to smooth the movement of the wheels @Chris Suggested

 

      {

      digitalWrite(D1,HIGH);   // for forward movement  

      analogWrite(P1, value);   //PWM Speed Control

      delay(200);

      }

    }

    analogWrite(P1,0); // this is to keep the motor off by 1 second after above command is executed @birdmun suggested 

    delay(1000);

/* this is for the Forward movement as the D1 is set to LOW*/  

{

    int value;  //use a scale of 0 - 255

    for( value = 20; value <= 255; value+=20)

{

      digitalWrite(D1,LOW);   // for reverse movement @ Chris

      analogWrite(P1, value);   //PWM Speed Control

      delay(200);

      }

    }

 

  }

 

digitalWrite(M1,LOW);

digitalWrite(M2,LOW);

I had updated the Code for the Reverse with help of Chris as below:

 

//Arduino PWM Speed Control:

 

int E1 = 5;  

int M1 = 4; 

int E2 = 6;                      

int M2 = 7;                        

 

void setup() 

pinMode(M1, OUTPUT);   

    pinMode(M2, OUTPUT); 

void loop()

  int value;

  for(value = 0 ; value <= 255; value+=5) 

    digitalWrite(M1,LOW);   // @Chris suggest for reverse movement

    digitalWrite(M2,LOW);   // @Chris suggest for reverse movement    

    analogWrite(E1, value);   //PWM Speed Control

    analogWrite(E2, value);   //PWM Speed Control

    delay(500); 

  }  

}

 

 

If you would like your motors to go the other way, make your dir (DIRection) pins low instead of high. 

In terms of +=5 and -=5... That is just going to be the normal function of the "for-loop" you are using. In theory, it should be

for(i=0;i<255;i+=5)

--or--

for(i=255;i>0;i-=5)

Hi Chris sorry for my weak knowledge. Please elaborate how to make the DIRection Pin to low? is there way you can write an code line for me so i can insert and try on my board and give feedback.

Hi all,

totday i got the delivery of the Motor Controller L298P. It has 10Pinout the picture are below: 

Front: http://i1265.photobucket.com/albums/jj519/soni991/RC%20Car/IMG_6712.jpg

Back: http://i1265.photobucket.com/albums/jj519/soni991/RC%20Car/IMG_6711.jpg

I connected L298P and Mega 2560 as below:

 

L298P    ====    Mega 2560

D1--------------------- 7 Digital

P1--------------------- 6 Digital

D2--------------------- 4 Digital

P2--------------------- 5 Digital

+5 --------------    Vin pin( I need ask the L298P board have 2 pins of VCC so where should i connect that?is it safe i connect to Vin?)

GND------------------ GND point

Connected Battery 9.6v NiCad Negative point  to the " - " sign and the positive to an swith then to " + " of the L298P board respectively.

The code to test and do little Homework as below :

_______________________________________________________________________________:

 

//Arduino PWM Speed Control:

int E1 = 5;  

int M1 = 4; 

int E2 = 6;                      

int M2 = 7;                        

void setup() 

pinMode(M1, OUTPUT);   

    pinMode(M2, OUTPUT); 

void loop()

  int value;

  for(value = 0 ; value <= 255; value+=5) 

    digitalWrite(M1,HIGH);   

    digitalWrite(M2, HIGH);       

    analogWrite(E1, value);   //PWM Speed Control

    analogWrite(E2, value);   //PWM Speed Control

    delay(500); 

  }  

}

 

 

_______________________________________________________________________________:

 

I tried few experiment by changing value+=5 to -=5 and found that in case of +=5 the speed moved in from 255 to 0 and in case of -=5 the speed moved from 0 to 255.

i change the delay command to "500" to notice the change of movement where as this function i believe is depend on the programers choice.

i cannot figure out is how to i make the motor reverse movement. Please advice !