Ali Soomar
Published

Internet-controlled RC Car

A cool RC Car that you can control with the touch of your fingers right from your own phone.

BeginnerShowcase (no instructions)1 hour2,304
Internet-controlled RC Car

Things used in this project

Story

Read more

Code

RC Car Program

C/C++
#define BLYNK_PRINT Serial    
#include <SPI.h>
#include <WiFi.h>
#include <BlynkSimpleEnergiaWiFi.h>

//Obtain your Authentication Token from the Blynk app
char auth[] = "Authentication"  ;    

// Your WiFi credentials
char ssid[] = "WiFi Name";          
char pass[] = "WiFi Password";      // Set to "" for open networks

void setup() {
  // put your setup code here, to run once:
  analogReadResolution(12);
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);

  pinMode(29, OUTPUT); //MOTOR 1
  pinMode(30, OUTPUT);

  pinMode(32, OUTPUT); //MOTOR 2
  pinMode(31, OUTPUT); 
}

BLYNK_WRITE(V0)//FORWARD
{
  //Print to the terminal
  BLYNK_LOG("Got a value: %s", param.asStr());
  
  int i = param.asInt(); 
  if(i == 1)
  {
   digitalWrite(29, HIGH);
   digitalWrite(30, LOW); //LEFT MOTOR GOES FORWARD

   digitalWrite(32, HIGH);
   digitalWrite(31, LOW); //RIGHT MOTOR GOES FORWARD
  }
  else if(i == 0)
  {
   digitalWrite(29, LOW);
   digitalWrite(30, LOW); //LEFT MOTOR STOPS

   digitalWrite(32, LOW);
   digitalWrite(31, LOW); //RIGHT MOTOR STOPS
  }
}

BLYNK_WRITE(V1)//TURN RIGHT
{
  //Print to the terminal
  BLYNK_LOG("Got a value: %s", param.asStr());
  
  int n = param.asInt(); 
  if(n == 1)
  {
   digitalWrite(29, HIGH);
   digitalWrite(30, LOW); //LEFT MOTOR GOES FORWARD

   digitalWrite(32, LOW);
   digitalWrite(31, HIGH); //RIGHT MOTOR GOES BACKWARDS
  }
  else if(n == 0)
  {
   digitalWrite(29, LOW);
   digitalWrite(30, LOW); //LEFT MOTOR STOPS

   digitalWrite(32, LOW);
   digitalWrite(31, LOW); //RIGHT MOTOR STOPS
  }
}

BLYNK_WRITE(V2)//BACKWARDS
{
  //Print to the terminal
  BLYNK_LOG("Got a value: %s", param.asStr());
  
  int m = param.asInt(); 
  if(m == 1)
  {
   digitalWrite(29, LOW);
   digitalWrite(30, HIGH); //LEFT MOTOR GOES BACKWARDS

   digitalWrite(32, LOW);
   digitalWrite(31, HIGH); //RIGHT MOTOR GOES BACKWARDS
  }
  else if(m == 0)
  {
   digitalWrite(29, LOW);
   digitalWrite(30, LOW); //LEFT MOTOR STOPS

   digitalWrite(32, LOW);
   digitalWrite(31, LOW); //RIGHT MOTOR STOPS
  }
}

BLYNK_WRITE(V3)//TURN LEFT
{
  //Print to the terminal
  BLYNK_LOG("Got a value: %s", param.asStr());
  
  int x = param.asInt(); 
  if(x == 1)
  {
   digitalWrite(29, LOW);
   digitalWrite(30, HIGH); //LEFT MOTOR GOES BACKWARDS

   digitalWrite(32, HIGH);
   digitalWrite(31, LOW); //RIGHT MOTOR GOES FORWARD
  }
  else if(x == 0)
  {
   digitalWrite(29, LOW);
   digitalWrite(30, LOW); //LEFT MOTOR STOPS

   digitalWrite(32, LOW);
   digitalWrite(31, LOW); //RIGHT MOTOR STOPS
  }
}

void loop() {
  Blynk.run();
}

Credits

Ali Soomar

Ali Soomar

11 projects • 37 followers
Student at the University of Texas at Austin

Comments

Add projectSign up / Login