MisterBotBreak
Published

How to Make a Three-Wheeled RC Car

This project will show you how to make a RC Car using 433MHz modules and L298N.

IntermediateFull instructions provided1 hour3,709
How to Make a Three-Wheeled RC Car

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
433MHz modules
×1
L298N module
×1
LED (generic)
LED (generic)
×2
Motor
×1
Resistor 10k ohm
Resistor 10k ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Transmitter

Arduino
#include <VirtualWire.h>

void setup() {
  Serial.begin(9600);
  vw_setup(2000);
}
 
void loop() {
  int valeurs[2];
  valeurs[0] = analogRead(0);
  valeurs[1] = analogRead(1);
  
  vw_send((byte *) &valeurs, sizeof(valeurs)); 
  vw_wait_tx(); 
  
  delay(50);
}

Receiver ( on the car )

Arduino
#include <VirtualWire.h>

#define ENA 5
#define ENB 6
#define IN2 8
#define IN3 9

void forward(){ 
  digitalWrite(ENA,HIGH); 
  digitalWrite(ENB,HIGH); 
  digitalWrite(IN2,HIGH); 
  digitalWrite(IN3,HIGH);  
}

void back(){
  digitalWrite(ENA,HIGH);
  digitalWrite(ENB,HIGH);
  digitalWrite(IN2,LOW);
  digitalWrite(IN3,LOW);
}

void left(){
  digitalWrite(ENA,HIGH);
  digitalWrite(ENB,HIGH);
  digitalWrite(IN2,HIGH);
  digitalWrite(IN3,LOW);
}

void right(){
  digitalWrite(ENA,HIGH);
  digitalWrite(ENB,HIGH);
  digitalWrite(IN2,LOW);
  digitalWrite(IN3,HIGH);
}


void setup() {
  Serial.begin(9600);
  vw_setup(2000);
  vw_rx_start();
  pinMode(13,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(IN2,OUTPUT);
  pinMode(IN3,OUTPUT);
  pinMode(ENA,OUTPUT);
  pinMode(ENB,OUTPUT);

  digitalWrite(10,1);
  digitalWrite(13,1);


}

void loop() {
 
  int valeurs[2];
  byte message = sizeof(valeurs);
  vw_wait_rx();

  if (vw_get_message((byte *) &valeurs, &message)){
  if(valeurs[0]>530){
    forward();  
  }
  if(valeurs[1]>530){
    right();    
  }
  if(valeurs[1]<480){
    left();    
  }    
  if(valeurs[0]<480){
    back();
  }
  if(valeurs[0]>480){
    if(valeurs[0]<530){
      if(valeurs[1]>480){
        if(valeurs[1]<530){
          digitalWrite(ENA,LOW);
          digitalWrite(ENB,LOW);
          }
        }
      }
    }
  }  
}

Credits

MisterBotBreak
48 projects • 152 followers
I love electronics and cats :D !

Comments