Hardware Details :
• Arduino Uno R4 WiFi +
• iOS 18 + iPhone 13 Pro/ iPhone 15 Pro
• blynk.cloud:80
• Blynk 1.3.2 - Arduino IDE Library
Hello Blynk developers and users,
Recently, I made a RC car using Blynk, an Arduino Uno R4 WiFi, and an L298N motor driver. Everything works great, and I can easily control the car. However, I was just wondering, is it possible to control the car using a PHYSICAL controller, instead of having to go to a phone, into the Blynk app, and controlling it that way?
Currently, I’m using 4 datastreams, each one correspnding to a diffrerent direction that the car will go.
Here is my code (It might be quite confusing since I put the motors on the worng way, and I just edited the code):
#define BLYNK_PRINT Serial
/* Fill in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "TMP*******"
#define BLYNK_TEMPLATE_NAME "*******"
#define BLYNK_AUTH_TOKEN "*********************************"
#include <SPI.h>
#include <WiFiS3.h>
#include <BlynkSimpleWifi.h>
#include <MotorDriver.h>
MotorDriver m;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "*************";
char pass[] = "**************";
int motor1pin1 = 2;
int motor1pin2 = 3;
int motor2pin1 = 4;
int motor2pin2 = 5;
void setup()
{
pinMode(motor1pin1, OUTPUT);
pinMode(motor1pin2, OUTPUT);
pinMode(motor2pin1, OUTPUT);
pinMode(motor2pin2, OUTPUT);
// Debug console
Serial.begin(9600);
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
// You can also specify server:
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
}
BLYNK_WRITE(V2){
int value = param.asInt();
if (value == 1) {
digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1, HIGH);
digitalWrite(motor2pin2, LOW);
}
else if (value == 0) {
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1, LOW);
digitalWrite(motor2pin2, LOW);
}
}
BLYNK_WRITE(V1){
int value1 = param.asInt();
if (value1 == 1) {
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, HIGH);
digitalWrite(motor2pin1, LOW);
digitalWrite(motor2pin2, HIGH);
}
else if (value1 == 0) {
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1, LOW);
digitalWrite(motor2pin2, LOW);
}
}
BLYNK_WRITE(V4) {
int value2 = param.asInt();
if (value2 == 1) {
digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1, LOW);
digitalWrite(motor2pin2, HIGH);
}
else if (value2 == 0) {
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1, LOW);
digitalWrite(motor2pin2, LOW);
}
}
BLYNK_WRITE(V3) {
int value3 = param.asInt();
if (value3 == 1) {
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, HIGH);
digitalWrite(motor2pin1, HIGH);
digitalWrite(motor2pin2, LOW);
}
else if (value3 == 0) {
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1, LOW);
digitalWrite(motor2pin2, LOW);
}
}
BLYNK_WRITE(V5) {
slider = paramn.asInt();
}
void loop()
{
Blynk.run();
}
If you need any clarification on the code, just reply :