I wanted to make a robot. However, I could only make a foot because my money ran out.
ConstitutionTwo servo motors are controlled by ESP32. ESP32 is controlled by smartphone app Blynk via WiFi.
I made a cool body with cardboard.
Inside is like this.
The smartphone and the ESP32 board make WiFi communication using the Blynk. Move the foot with the forward / reverse button. The Blynk app version is 2.27.5.
Create a new project HARDWRE MODEL selects ESP32 Dev Board. CONNECTION TYPE select WiFi. AUTH TOKEN is used when generating Arduino code (sent by email).
Arrange two button widgets and make them forward / reverse buttons.
Select virtual pin V0 in INPUT of the advance button widget. The reverse button also selects virtual pin V1.
Arduino IDE code
The following program was programmed using Blynk's library for Arduino. The version is 0.6.1.https://github.com/blynkkk/blynk-library
Arduino for ESP32 library is version 1.0.0.
I also used the servo motor library ESP32Servo for ESP32.https://github.com/madhephaestus/ESP32Servo
The Blynk button push is detected to move the servo forward or backward.
#include <ESP32Servo.h>
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken for Blynk";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "WiFi SSID";
char pass[] = "pass";
Servo myservo1, myservo2;
int button1 = 0, button2 = 0;
int servoPin1 = 14, servoPin2 = 12;
//Forward button detection
BLYNK_WRITE(V0) {
button1 = param.asInt();
}
//Reverse button detection
BLYNK_WRITE(V1) {
button2 = param.asInt();
}
void setup()
{
Serial.begin(115200);
myservo1.setPeriodHertz(50); // standard 50 hz servo
myservo2.setPeriodHertz(50);
myservo1.attach(servoPin1, 1000, 2000);
myservo2.attach(servoPin2, 1000, 2000);
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
//Forward
if(button1){
myservo2.write(120);
delay(200);
myservo1.write(180);
delay(200);
for (int i = 1; i <= 30; i++) {
myservo1.write(180 - i * 3);
myservo2.write(120 + i * 2);
delay(10);
}
}
//Reverse
if(button2){
myservo2.write(180);
delay(200);
myservo1.write(90);
delay(200);
for (int i = 1; i <= 30; i++) {
myservo1.write(90 + i * 2);
myservo2.write(180 - i * 2);
delay(10);
}
delay(100);
myservo1.write(180);
delay(100);
}
}
OperationJust a small step. I have no idea how long it will take. But someday I want to make it a cool robot.
The following is the completion forecast
Comments