Introduction: How to Make Drift Car Using Arduino
Hi everybody. Let me introduce about how i made a DRIFT CAR using arduino, pololu VNH5019, NRC-20 control system and wrecked body of RC car.
Step 1: This DRIFT CAR Contains...
1. Arduino UNO R3 programmable board
2. Pololu Dual VNH5019 Motor Driver Shield for Arduino - https://www.pololu.com/product/2507
3. NRC-20 wireless control system
4. Li-Po battery 11.1V 2200mAh 35C 3S1P
5. Wrecked RC car with servo based on potentiometer and dc motor
Step 2: Connections
These will be connected leading to the picture
Step 3: Arduino Code
Download libraries and codes from github:
Main code: https://github.com/BTeTapxu/Drift-car-code-arduino
Download library: https://github.com/pololu/dual-vnh5019-motor-shield
CODE:
#include "DualVNH5019MotorShield.h"
DualVNH5019MotorShield motor;
unsigned char serial_in[7]={};
int i=0;
int analogPin = 3; // potentiometer connected to analog pin 3 int val = 0, comp;
void setup(){
Serial.begin(19200);
motor.init();
}
void loop(){
motor_move();
servo();
Serial.println(comp); //debug
if (Serial.available() > 0) {
if (i==6){
i=0;
}
i++;
serial_in[i]=Serial.read();
}
}
void servo() {
if(comp<map(serial_in[4],208,48, 14, 6)){
motor.setM2Speed(100);
}
else if(comp>map(serial_in[4],208,48, 14, 6)){
motor.setM2Speed(100);
}
else{
motor.setM2Speed(0);
}
comp=analogRead(analogPin)/50;
}
void motor_move() {
if(serial_in[1]<127){
motor.setM1Speed(map(serial_in[1],127,50, 0, -400));
}
else if(serial_in[1]>129){
motor.setM1Speed(map(serial_in[1],129,210, 0, 400));
}
else{
motor.setM1Speed(0);
}
}