So im trying to make a telepresence robot like ive seen on you tube. Ive copied code that wouldn’t compile and tweaked it to do atleast that but im stuck on the part were i connect a skype video stream from the android phone on the robot to the live video widget on the app. Would greatly appreciate any help i can get as this is my first attempt at connecting anything to wifi let alone video streams. Im making a tracked robot with a wemos mini D1 connected to a l298n. The app uses a joystick to control it but i cant figure out what pins i should connect the joystick to in the app (virtual/digital???) New to this app and hope im posting this right because it isn’t the most intuitive. This code as i said was codied and reworked to compile but im not sure.
Simply paste your code between ``` If you don’t format your code, your topic can be deleted by moderators.
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// Setup L298N Motor Controller Input Pins
int IN1 = D6; // Motor 2
int IN2 = D5; // Motor 2
int IN3 = D2; // Motor 1
int IN4 = D1; // Motor 1
int ENA = D7;
int ENB = D8;
int Flag = 1;
char incomingByte;
char auth[] = "vwARajksHH1xoQdpHyloPjQAC5uMkzK7";
char ssid[] = "MySpectrumWiFi0a-2G";
char pass[] = "***************";
void setup()
{
// setup L298N Motor Controller Input Pins
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(ENA, OUTPUT);
pinMode(ENB, OUTPUT);
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
analogWrite(ENA, 150);
analogWrite(ENB, 150);
}
BLYNK_WRITE(V6) // Joystick Widget Input
{
Flag = 1;
int y = param[1].asInt();
int x = param[0].asInt();
if (y > 750 && Flag == 1) { // Forward
Flag = 0;
incomingByte = '1';
ControlOutput();
}
if (y < 250 && Flag == 1) { // Backward
Flag = 0;
incomingByte = '2';
ControlOutput();
}
if (x < 250 && Flag == 1) { // Left
Flag = 0;
incomingByte = '3';
ControlOutput();
}
if (x > 750 && Flag == 1) { // Right
Flag = 0;
incomingByte = '4';
ControlOutput();
}
if (y == 512 && y == 512) { // Full Stop
incomingByte = '0';
ControlOutput();
}
}
BLYNK_WRITE(V0)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
digitalWrite(IN1, pinValue);
digitalWrite(IN2, pinValue);
digitalWrite(IN3, pinValue);
digitalWrite(IN4, pinValue);
}
// Take inputs and direct motor control functions
void ControlOutput() {
switch (incomingByte) {
case '1': {
motor1Forward();
motor2Forward();
Blynk.virtualWrite(V1, "Forward");
}
break;
case '2': {
motor1Backwards();
motor2Backwards();
Blynk.virtualWrite(V1, "Backward");
}
break;
case '3': {
motor1Backwards();
motor2Forward();
Blynk.virtualWrite(V1, "Spin Left");
}
break;
case '4': {
motor1Forward();
motor2Backwards();
Blynk.virtualWrite(V1, "Spin Right");
}
break;
default: {
Blynk.virtualWrite(V1, "Full Stop");
motor1Stop();
motor2Stop();
Flag = 1;
}
break;
}
}
// Functions to control L298N Motor Controller Input Pins
void motor1Forward() {
digitalWrite(IN4, HIGH);
digitalWrite(IN3, LOW);
}
void motor1Backwards() {
digitalWrite(IN4, LOW);
digitalWrite(IN3, HIGH);
}
void motor1Stop() {
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
}
void motor2Forward() {
digitalWrite(IN2, HIGH);
digitalWrite(IN1, LOW);
}
void motor2Backwards() {
digitalWrite(IN2, LOW);
digitalWrite(IN1, HIGH);
}
void motor2Stop() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
}
void loop()
{
Blynk.run();
}