Introduction: RC Car Using TinkerCad

In this instructable, I will show you how to build a remote control car. I used TinkerCad but this will work with a real Arduino as well.

Attachments

Supplies

  • 1 Arduino Uno R3
  • 2 9V Battery
  • 2 White LED
  • 3 Red LED
  • 9 1 kΩ Resistor
  • 1 Piezo
  • 2 DC Motor U3 1 H-bridge Motor Driver
  • 7 Pushbutton
  • 1 Slide switch
  • 1 10 kΩ Resistor

Step 1: Step 1: the Circuit

Step 2: Step 2: the Code

If you want to copy the code here it is:

const int motorPin1=A3;

const int motorPin2=A2;

const int motorPin3=A1;

const int motorPin4=A0;

const int enablePin=A5;

const int powerPin=2;

const int FrontPin=5;

const int BackPin=6;

const int LeftPin=4;

const int RightPin=3;

const int hornSwitchPin=7;

const int hornPin=12;

const int lightSwitchPin=8;

const int lightPin=13;

const int brakeLights=11;

const int brakePin=9;

const int reverseLights=10;

int power;

int front;

int back;

int left;

int right;

int horn;

int light;

int brake;

void setup(){

Serial.begin(9600);

pinMode(motorPin1, OUTPUT);

pinMode(motorPin2, OUTPUT);

pinMode(motorPin3, OUTPUT);

pinMode(motorPin4, OUTPUT);

pinMode(enablePin, OUTPUT);

pinMode(powerPin, INPUT);

pinMode(FrontPin, INPUT);

pinMode(BackPin, INPUT);

pinMode(LeftPin, INPUT);

pinMode(RightPin, INPUT);

pinMode(hornSwitchPin, INPUT);

pinMode(hornPin, OUTPUT);

pinMode(lightSwitchPin, INPUT);

pinMode(lightPin, OUTPUT);

pinMode(brakePin, INPUT);

pinMode(brakeLights, OUTPUT);

pinMode(reverseLights, OUTPUT);

}

void loop(){

power= digitalRead(powerPin);

Serial.println(power);

if(power == 1){

digitalWrite(enablePin, HIGH);

Serial.println("power");

}

else{

digitalWrite(enablePin, LOW);

}

horn=digitalRead(hornSwitchPin);

Serial.println(horn);

if(horn == 1){

digitalWrite(hornPin, HIGH);

}

else{

digitalWrite(hornPin, LOW);

}

brake=digitalRead(brakePin);

if(brake == 1){

digitalWrite(motorPin1, LOW);

digitalWrite(motorPin2, LOW);

digitalWrite(motorPin3, LOW);

digitalWrite(motorPin4, LOW);

digitalWrite(brakeLights, HIGH);

}

if(brake == 0){

digitalWrite(brakeLights, LOW);

}

light=digitalRead(lightSwitchPin);

if(light == 1){

digitalWrite(lightPin, HIGH);

}

if (light == 0){

digitalWrite(lightPin, LOW);

}

else{

digitalWrite(lightPin, LOW);

}

front=digitalRead(FrontPin);

back=digitalRead(BackPin);

left=digitalRead(LeftPin);

right=digitalRead(RightPin);

if(front == 1){

digitalWrite(motorPin1, HIGH);

digitalWrite(motorPin3, HIGH);digitalWrite(motorPin2, LOW);

digitalWrite(motorPin4, LOW);

}

else if(back == 1){

digitalWrite(motorPin2, HIGH);

digitalWrite(motorPin4, HIGH);

digitalWrite(motorPin1, LOW);

digitalWrite(motorPin3, LOW);

}

else if(left == 1){

digitalWrite(motorPin1, LOW);

digitalWrite(motorPin2, LOW);

digitalWrite(motorPin3, HIGH);

digitalWrite(motorPin4, LOW);

}

else if(right == 1){

digitalWrite(motorPin1, HIGH);

digitalWrite(motorPin2, LOW);

digitalWrite(motorPin3, LOW);

digitalWrite(motorPin4, LOW);

}

}