Anthony MillerDustin Jones
Published

IoT RC Car

Converting a RC car to an IoT car with a Particle Photon and controlling it with the Blynk app.

IntermediateFull instructions provided12 hours288
IoT RC Car

Things used in this project

Hardware components

RC Car
×1
LED (generic)
LED (generic)
×12
Resistor 100 ohm
Resistor 100 ohm
×2
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Photon
Particle Photon
×2
L298N Motor Drive Controller Board
×1
Breadboard (generic)
Breadboard (generic)
×1
Double Sided Tape
×1
18 Gauge Wire
×1
14 Gauge Wire
×1
Android device
Android device
×1

Software apps and online services

Blynk
Blynk
Particle Build Web IDE
Particle Build Web IDE

Hand tools and fabrication machines

Drill / Driver, Cordless
Drill / Driver, Cordless
with a 3/16" drill bit
Soldering iron (generic)
Soldering iron (generic)
Wire Stripper & Cutter, 32-20 AWG / 0.05-0.5mm² Solid & Stranded Wires
Wire Stripper & Cutter, 32-20 AWG / 0.05-0.5mm² Solid & Stranded Wires

Story

Read more

Schematics

Circuit Diagram

Code

First Photon Code (publish)

C/C++
This code was flashed on the first photon, which controls the car. The part that says "Auth Token" is were you type your token you get from the Blynk app.
int ledPinD5=D5;
int ledPinD4=D4;

unsigned long lastTime1 = 0;
unsigned long lastTime2 = 0;
const long interval =600;

// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>

#define BLYNK_PRINT Serial

char auth[] = "Auth Token";

void setup()

{
    Serial.begin(9600);
    
    delay(5000); //Allow board to settle
    
    Blynk.begin(auth);
}
    
void loop() {
    
    unsigned long now = millis();
    Blynk.run();
    
    
	
	if (((now - lastTime1) >= interval) && digitalRead(ledPinD5)==HIGH ){
	    
		lastTime1 = now;
		Particle.publish("LEFT","NASCAR",PUBLIC);
	}
	
	if (((now - lastTime2) >= interval) && digitalRead(ledPinD4)==HIGH ){
	    
		lastTime2 = now;
		Particle.publish("RIGHT","NOT-NASCAR",PUBLIC);
		
	}
}

Second Photon Code (Subscribe)

C/C++
This code was flashed to the second photon. The "Auth Token" is the same as the first code.
int led = D7;
int out = D0;
int out2 = D6;

void setup() {
    pinMode(led, OUTPUT);
    pinMode(out, OUTPUT);
    pinMode(out2, OUTPUT);
    digitalWrite(led,LOW);
    digitalWrite(out,LOW);
    digitalWrite(out2,LOW);
    
    
    Particle.subscribe("LEFT", responseLeft, "Auth Token");
    Particle.subscribe("RIGHT", responseRight, "Auth Token");
    
}

void responseLeft(const char *event, const char *data){
    digitalWrite(led, HIGH);
    delay(100);
    digitalWrite(led,LOW);
    delay(100);
    digitalWrite(out,HIGH);
    delay(100);
    digitalWrite(out,LOW);
    delay(100);
}

void responseRight(const char *event, const char *data){
     digitalWrite(led, HIGH);
    delay(100);
    digitalWrite(led,LOW);
    delay(100);
    digitalWrite(out2,HIGH);
    delay(100);
    digitalWrite(out2,LOW);
    delay(100);
}

void loop() {
    
}

Credits

Anthony Miller

Anthony Miller

1 project • 1 follower
Dustin Jones

Dustin Jones

0 projects • 0 followers

Comments

Add projectSign up / Login