#include <BlynkSimpleEsp32.h>
#define BLYNK_TEMPLATE_ID "TMPL3iPUd1z46"
#define BLYNK_TEMPLATE_NAME "RC boat"
#define BLYNK_AUTH_TOKEN "NEzNik8ig474yDUZZCWFHzvo29hl9A3O"
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "11111111";
#define motorPin1 15 // Connect to motor driver input 1
#define motorPin2 2 // Connect to motor driver input 2
#define motorSpeedPin 4 // Connect to motor driver input for PWM speed control
BLYNK_WRITE(V1) {
int value = param.asInt();
if (value == 1) {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
} else {
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
}
}
void setup() {
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorSpeedPin, OUTPUT);
analogWrite(motorSpeedPin, 0); // Initialize motor speed to 0
}
void loop() {
Blynk.run();
}