#define BLYNK_TEMPLATE_ID "TMPL6aBQ617N1"
#define BLYNK_TEMPLATE_NAME "Quickstart Template"
#define BLYNK_AUTH_TOKEN "J2IPqtpNUvbPrxrDecAU0x1NvDdDvM8V"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <ESP32Servo.h>
int i = 0;
int c = 1;
int a =0;
#define f0 15
#define f1 21
#define f2 22
#define f3 23
#define f4 16
const int servoPin = 17;
const int servoPin1 = 18;
const int servoPin2 = 19;
Servo servo;
Servo servo2;
Servo conveyor;
Servo conveyor2;
Servo bushless;
Servo bushless2;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
BlynkTimer timer;
BLYNK_WRITE(V0)
{
int value = param.asInt();
if (value == HIGH) {
for(i=0;i<=c;i++){
bushlessw();
delay(50);
}
c = 0;
if(i==1){
digitalWrite(f1, HIGH);
servow();
delay(15);
conveyorw();
delay(15);
servow2();
delay(15);
bushlessw2();
delay(50);
digitalWrite(f1, LOW);
digitalWrite(f0, HIGH);
}
Serial.println((c));
} else {
}
}
BLYNK_WRITE(V1)
{
int value1 = param.asInt();
if (value1 == HIGH) {
for(i=0;i<=c;i++){
bushlessw();
delay(15);
}
if(i==2){
digitalWrite(f2, HIGH);
servow2();
delay(15);
conveyorw2();
delay(15);
servow();
delay(15);
for(i=2;i>0;i--){
bushlessw();
delay(15);
}
conveyorw();
delay(15);
digitalWrite(f0, HIGH);
c=1;
}
}
}
BLYNK_WRITE(V5)
{
int value2 = param.asInt();
if (value2 == HIGH) {
}
}
BLYNK_WRITE(V3)
{
int value3 = param.asInt();
if (value3 == HIGH) {
}
}
BLYNK_WRITE(V4)
{
int value4 = param.asInt();
if (value4 == HIGH) {
}
}
BLYNK_CONNECTED()
{
Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
Blynk.setProperty(V3, "onImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}
void myTimerEvent()
{
Blynk.virtualWrite(V2, millis() / 1000);
}
void servow(){
servo.attach(servoPin, 500, 2400);
}
void servow2(){
servo2.attach(servoPin, 500, 2400);
}
void conveyorw(){
conveyor.attach(servoPin1, 500, 2400);
}
void conveyorw2(){
conveyor2.attach(servoPin1, 500, 2400);
}
void bushlessw(){
bushless.attach(servoPin2, 500, 2400);
}
void bushlessw2(){
bushless2.attach(servoPin2, 500, 2400);
}
void setup()
{
Serial.begin(115200);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(100);
Serial.print(".");
}
Serial.println(" Connected!");
pinMode(f0, OUTPUT);
pinMode(f1, OUTPUT);
pinMode(f2, OUTPUT);
pinMode(f3, OUTPUT);
pinMode(f4, OUTPUT);
digitalWrite(f0, LOW);
digitalWrite(f1, LOW);
digitalWrite(f2, LOW);
digitalWrite(f3, LOW);
digitalWrite(f4, LOW);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(1000L, myTimerEvent);
}
int pos = 0;
int pos1 = 0;
int pos2 = 0;
void loop()
{
for (pos = 0; pos <= 90; pos += 1) {
servo.write(pos);
delay(15);
}
for (pos = 90; pos >= 0; pos -= 1) {
servo2.write(pos);
delay(15);
}
for (pos1 = 0; pos1 <= 90; pos1 += 1) {
conveyor.write(pos1);
delay(15);
}
for (pos1 = 90; pos1 >= 0; pos1 -= 1) {
conveyor2.write(pos1);
delay(15);
}
for (pos2 = 0; pos2 <= 90; pos2 += 1) {
bushless.write(pos2);
delay(15);
}
for (pos2 = 90; pos2 >= 0; pos2 -= 1) {
bushless2.write(pos2);
delay(15);
}
Blynk.run();
timer.run();
}