Hi , I have managed to get one of my sensor to display data through the blynk app using virtual pin V5. However, when I tried doing the same with another sensor it doesn’t work.
Can someone tell me what is wrong with my code perhaps.
#define BLYNK_PRINT DebugSerial
#define TRIGGER 12
#define ECHO 13
#define TRIGGER1 11
#define ECHO1 10
// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(0, 1); // RX, TX
#include <BlynkSimpleStream.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "2GjplOIwgjtoMkwlANEzAzdliDX8jpBr";
BLYNK_WRITE(V5)
{
int pinValue = param.asInt ();
}
BLYNK_WRITE(V4)
{
int pinValue1 = param.asInt ();
}
void setup()
{
// Debug console
DebugSerial.begin(9600);
// Blynk will work through Serial
// Do not read or write this serial manually in your sketch
Serial.begin(9600);
Blynk.begin(Serial, auth);
pinMode(TRIGGER, OUTPUT);
pinMode(ECHO, INPUT);
pinMode(TRIGGER1, OUTPUT);
pinMode(ECHO1, INPUT);
}
void loop()
{
long duration, distance,duration1,distance1;
digitalWrite(TRIGGER, LOW);
delayMicroseconds(2);
digitalWrite(TRIGGER, HIGH);
delayMicroseconds(10);
digitalWrite(TRIGGER, LOW);
duration = pulseIn(ECHO, HIGH);
distance = (duration/2)/29.1;
Blynk.virtualWrite(V5, distance);
digitalWrite(TRIGGER1, LOW);
delayMicroseconds(2);
digitalWrite(TRIGGER1, HIGH);
delayMicroseconds(10);
digitalWrite(TRIGGER1, LOW);
duration1 = pulseIn(ECHO1, HIGH);
distance1 = (duration1/2)/29.1;
Blynk.virtualWrite(V4, distance1);
delay(200);
Blynk.run();
}