i tried to compile this code in the arduino ide but it keep saying:
‘class BlynkWifi’ has no member named ‘virtualRead’ did you mean ‘virtualWrite’?
any help in fixing this error !!, remember im using an esp32 board the code i uses is the following
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// WiFi credentials
char ssid[] = "your_SSID";
char pass[] = "your_PASSWORD";
// Blynk authentication token
char auth[] = "your_AUTH_TOKEN";
// IR sensor pins
int sensor1 = 2;
int sensor2 = 3;
int sensor3 = 4;
int sensor4 = 5;
// Servo motor pin
int servoPin = 12;
// LCD pins
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Servo motor object
Servo servo;
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Initialize WiFi connection
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
// Initialize Blynk connection
Blynk.begin(auth, WiFi.SSID().c_str(), WiFi.psk().c_str());
// Initialize IR sensor pins as inputs
pinMode(sensor1, INPUT);
pinMode(sensor2, INPUT);
pinMode(sensor3, INPUT);
pinMode(sensor4, INPUT);
// Initialize servo motor pin as output
pinMode(servoPin, OUTPUT);
// Attach servo motor to pin
servo.attach(servoPin);
// Initialize LCD
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Smart Parking");
}
void loop() {
// Read IR sensor values
int value1 = digitalRead(sensor1);
int value2 = digitalRead(sensor2);
int value3 = digitalRead(sensor3);
int value4 = digitalRead(sensor4);
// Check if parking spots are available
if (value1 == LOW || value2 == LOW || value3 == LOW || value4 == LOW) {
// Display available spots on LCD
lcd.setCursor(0, 1);
lcd.print("Available: ");
lcd.print(value1 == LOW ? "1 " : "");
lcd.print(value2 == LOW ? "2 " : "");
lcd.print(value3 == LOW ? "3 " : "");
lcd.print(value4 == LOW ? "4 " : "");
// Wait for reservation from Blynk app
while (Blynk.connected()) {
Blynk.run();
if (Blynk.virtualRead(1) == 1) {
// Reserve parking spot
int spot = Blynk.virtualRead(2).asInt();
if (spot == 1) {
servo.write(0);
delay(1000);
lcd.setCursor(0, 1);
lcd.print("Reserved: 1 ");
} else if (spot == 2) {
servo.write(45);
delay(1000);
lcd.setCursor(0, 1);
lcd.print("Reserved: 2 ");
} else if (spot == 3) {
servo.write(90);
delay(1000);
lcd.setCursor(0, 1);
lcd.print("Reserved: 3 ");
} else if (spot == 4) {
servo.write(135);
delay(1000);
lcd.setCursor(0, 1);
lcd.print("Reserved: 4 ");
}
break;
}
}
} else {
// Display no available spots on LCD
lcd.setCursor(0, 1);
lcd.print("No available spots");
}
}