SOCIALS 

SUBSCRIBE 

 Please subscribe.   So, you will get notification of the latest exciting posts. 

© 2023 by FEEDs & GRIDs. Proudly created with Wix.com

ABOUT FEEDs & GRIDs

My name is Mike.   This blog is made especially for you to enter my technology universe.  You will find new ideas and skills that may be helpful to you.   Feel free to leave your comments.   I am excited to hear from you.  Thank you. 

Arduino UNO Based Remote Controlled Toy Car (Version 1.0 with 433Mhz RF)

September 30, 2017

Project Description:

 

This is a simple Arduino project that uses the popular Arduino UNO R3 and NANO to build a remote controlled toy car.   An inexpensive and short distance wireless kit is used for transmitting the X and Y positions of the joystick to the toy car.   

 

The Y position controls the direction (foward or backward) and speed of the toy car movement.   The X position controls the turn of the toy car for no turn, left turn, or right turn.  (See diagram 1.)  

 

The front and back distance sensor detects how close the toy car is to an object ahead or behind.   If the distance is too close, the toy car will come to an immediate stop by overriding the user's specified speed.

 

Diagram 1. 

 Note: The XY range for the joystick is actually from 0 to 1023.  For a larger step change in better toy car's speed control, the range is modified as shown here.

 

Demo Video: 

 

 

Video 1: Toy Car Brake Demonstration.   The toy car will stop when it comes too close to a wall.

 

Video 2: Toy Car Turn Demonstraion. 

 

 

Hardware Overview: 

 

Figure 1a: An Arduino UNO R3 based toy car with a remote control module.

Figure 1b: Parts' Description.

 

 

Figure 2: The Arduino UN0 R3 processor board.

 Figure 3: The two DC motors and three wheels on the bottom side of the toy car.

 

 Figure 4: The 9V battery on the bottom of the remote module and the side view of the wireless module.

 

Figure 5: The new X and Y positions of the joystick is shown on both displays.    The positions are transmitted to the toy car as the user changes them.

 

Part List

 

The part List for the toy car: (the prices may be subject to changes without notice)

 

(Motor related parts)

1. Motor Robot Car Chassis Kit (DC motors + 3 wheels)  $14 (Amazon link)

2. L298N Motor Drive Controller (5 pieces) $15 (Amazon link) - Only 1 pieces is required for the toy car.

 

(CPU parts)

3. Elegoo UNO R3 Board for Arduino $11 (Amazon link)

4. Longruenr Mini Nano for Arduino (5 pieces) $20 (Amazon link) - only 1 piece required for the remote control module)

 

(Wireless Radio Frequency parts)

5. 433Mhz RF Transmitter With Receiver Kit $4 (Bandgood link) - The transmitter for the remote control module and the receiver for the toy car.

* The antenna is just a homemade twisted wire.

 

(Sensor parts)

6. HC-SR04 Ultrasonic Sensor Distance Module (5 pieces) $10 (Amazon link) - only 2 pieces required for this project)

 

(Display parts)

7.  Diymall 0.96" Inch Yellow and Blue I2c IIC Serial 128x64 Oled LCD (2 pieces) $17 (Amazon link)  - 1 piece for the toy car and 1 pieces for the remote control module.

 

(Interface part)

8. FICBOX XY Joystick Module (1 piece) $? (Don't buy from Amazon.  Try Banggood.com) - Only 1 pieces is required for the remote control module.

 

(Battery)

9. 9v Battery Clip Snap Accessories (5 pieces) $7 (Amazon link) - use the male end to connect the battery to the electronic parts.  Only 2 pieces are required for this project.

10. DC Power Jack Socket 2.1mm x 5.5mm (15 pieces) $8 (Amazon link) or (Fry's electronic store) - Only 1 piece is required for the project.

11. Two 9V Batteries $5 (Fry's electronic store)

12. Two 9V battery cases. (2 pieces) $4 (Fry's electronic store)

13 Two Tenergy 3.7V 2600mAh 18650 Li-ion Rechargeable Batteries $20 (Fry's electronic store)

14 Two Li-ion Rechargeable Battery Cases (unknown price) (Fry's electronic store)

 

(Misc.)

15. M2 screws and nuts (10 pieces) or 2-56 3/8" screws and small nuts (HSC)

16. Alloet Mini Breadboard Prototyping Prototype Shield for Arduino UNO (5 pieces) $12 (Amazon link) or Adafruit Prototype Shield for Arduino UNO (1 piece) $15 (Adafruit link)

 

Total cost estimation:  ~$131  

 

* Only $89 worth parts of $131 are used for this project.  Extra unused parts can be saved for your next project.

 

Schematic

 

Figure 6: Remote Control Module Fritzing Breadboard Diagram.

Figure 7: Remote Control Module Fritzing Schematic Diagram.

Figure 8: Main Module Fritzing Breadboard Diagram.

 

 

 

Figure 9: Main Module Fritzing Schemaitc Diagram.

 

 

Software Overview

 

1. RecieveDemo_rc_car_xy_0.ino (example)

 

  Target board: Arduino UNO R3 (Toy Car)

 

  Example: This code is written for the processor which recieves
           the X and Y positions of the joystick from the remote
           control module.   The processor will translate the 
           positions to contorl the two DC motors' speed and direction.

 

 Main Loop Code:

 

 

void loop() {
  if (mySwitch.available()) {
      process_motor();     
Get the XY poistions from RF reciever and send new control

                                           (direction, speed, turn) to DC motors.
  }  
  unsigned long current_time = millis();

  if ((current_time - time_prev_chkdist) > interval_chkdist) {
    time_prev_chkdist = current_time;  
    if (scan_state) {
      process_distance_sensor_front();   
 Get the distance from the front sensor
      scan_state = false;
    } else {
      process_distance_sensor_back();   
Get the distance from the rear sensor
      scan_state = true;
    }
    if (distance_front_data > IGNORE_DISTANCE && distance_front_data < CLEAR_DISTANCE && speedDir == DIR_FORWARD) {  // Don't go any further.             
       forward_brake_flag = true;
    } 
    if (distance_back_data > IGNORE_DISTANCE && distance_back_data < CLEAR_DISTANCE && speedDir == DIR_BACKWARD) {  // Don't go any further.        
       backward_brake_flag = true;
    }
    if (forward_brake_flag | backward_brake_flag) {   
Decide whether the toy car needs to stop now.
       speedValue = 0;         
       speedValueL = speedValue; 
       speedValueR = speedValue; 
       drive_motor(speedDir,speedValueL,speedValueR); 
    }              
    update_oled_display(sensorValue_x, sensorValue_y, speedDir, speedValue,     distance_front_data,distance_back_data,forward_brake_flag,backward_brake_flag);

  }  
}

 

2. SendDemo_rc_car_xy_0.ino (example)

 

  Target board: Arduino NANO (Remote Control Module)

 

  Example: This code is written for the processor which transmitts
           the X and Y positions of the joystick to the toy
           car.   

 

Main loop code:  

 

void loop() {
  unsigned long current_time = millis();

  if ((current_time - time_prev_senddata) > interval_senddata) {
    //update_oled_display (count, 0, 0, 0);
    //mySwitch.send(count,datalength);     
    if (x_position == 0) {
      x_position = 1;
    }
    if (y_position == 0) {
      y_position = 1;
    }
    update_oled_display (x_position, y_position);

    senddata = (x_position * 256) + y_position; 
    Serial.println(x_position);
    Serial.println(y_position);  
    Serial.println(senddata);  
    mySwitch.send(senddata,datalength);   
Send the xy positions out by RF  
    if (count_send < count_send_max) {
       count_send++;
    } else {
      count_send = 0;
      count++;  
      tempdata = analogRead (JoyStick_Y);   
 Read the Y position
      y_position = map (tempdata, 0, YRAW_MAX, 0, YPOS_MAX);
      tempdata = analogRead (JoyStick_X);   
 Read the X position
      x_position = map (tempdata, 0, XRAW_MAX, 0, XPOS_MAX);
    }    
    time_prev_senddata = current_time;
  }  
}


Libraries included in this repository:

 

1. Adafruit_GFX_Library : Support OLED display

2. Adafruit_SSD1306_Lite : Support OLED display (up to 4 lines of text only to conserve RAM space for Arduino)

3. RCSwitch : Support wireless 433Mhz modules
 

Note: Adafruit SSD1306_Lite is a modified version from Adafruit_SSD1306.  Because Arduino UNO R3/NANO has only 2K bytes of on-board RAM.   The display library RAM usage needs to be reduced from 1K to 512 bytes in order to avoid the programs from crashing due to the low RAM issue.

 

Here is the link to the code download (Gibhub).

 

Conclusion:

 

The project is very educational because it involves understanding of many different components that need to work together.   

 

There is an important area for improvement.   A better antenna can help significantly how well the wireless receiver can get the signal properly over a longer range of distance.   A better wireless module NRF24L01 can be used for this project.

 

 

 

Share on Facebook
Share on Twitter
Please reload

RECENT POSTS

Please reload

FEATURED POSTS

I2C Tutorial for Renesas S5D9 board: Add ThreadX real time OS support. (Part 3)

February 18, 2018

1/5
Please reload

FOLLOW US

  • Grey Facebook Icon
  • Grey Twitter Icon
  • Grey Instagram Icon
  • Grey Google+ Icon
  • Grey Pinterest Icon
This site was designed with the
.com
website builder. Create your website today.
Start Now