#define BLYNK_PRINT Serial
#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL40SakZQT6"
#define BLYNK_TEMPLATE_NAME "unmanned_vision"
#define BLYNK_AUTH_TOKEN "OMs438REbNzHS7tLqNzDbp5hEuKTB7vz"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#define sensor 33
char ssid[] = "AVDESO_TECH";
char pass[] = "12344321";
int in1Pin = 12;
int in2Pin = 14;
int enAPin = 13;
int motorSpeed = 0;
void setup()
{
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
pinMode(in1Pin, OUTPUT);
pinMode(in2Pin, OUTPUT);
pinMode(enAPin, OUTPUT);
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void soilsensor() {
int value = analogRead(sensor);
value = map(value, 0, 4095, 0, 100);
value = (value - 100) * -1;
Blynk.virtualWrite(V2, value);
Serial.println(value);
}
BLYNK_WRITE(V1)
{
int buttonState = param.asInt();
if (buttonState == 1) {
digitalWrite(in1Pin,HIGH);
digitalWrite(in2Pin,LOW);
delay(1000);
} else {
digitalWrite(in1Pin,LOW);
digitalWrite(in2Pin,LOW);
}
}
void loop()
{
Blynk.run();
soilsensor();
}
esp32
RELATED ARTICLES