Hello, I’m having trouble working on virtual pin and notification using arduino mega… I used nodemcu and it worked perfect, but in arduino mega it didn’t.
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3); // RX, TX
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxx";
void setup()
{
Serial.begin(9600);
Blynk.begin(auth);
}
void LED()
{ WidgetLED led0(V0);
WidgetLED led1(V1);
WidgetLED led2(V2);
WidgetLED led3(V3);
WidgetLED led4(V4);
WidgetLED led5(V5);
WidgetLED led7(V7);
WidgetLED led8(V8);
if (digitalRead(D0) == HIGH )
{
led0.on();
}
else
{
led0.off();
}
if (digitalRead(D1) == HIGH )
{
led1.on();
}
else
{
led1.off();
}
if (digitalRead(D2) == HIGH )
{
led2.on();
}
else
{
led2.off();
}
if (digitalRead(D3) == HIGH )
{
led3.on();
}
else
{
led3.off();
}
if (digitalRead(D4) == HIGH )
{
led4.on();
}
else
{
led4.off();
}
if (digitalRead(D5) == HIGH )
{
led5.on();
}
else
{
led5.off();
}
if (digitalRead(D6) == LOW )
{
led7.on();
delay(1000);
Blynk.email("xxxxxx","xxxx","xxxxxxxx");
}
else
{
led7.off();
}
if (digitalRead(D7) == LOW )
{
led8.off();
}
else
{
led8.on();
delay(1000);
Blynk.email("xxxxx,"xxxx!","xxxxx");
}
}
BLYNK_WRITE(V6)
{
int virtualPin6 = param.asInt();
if (virtualPin6 == 1 )
{
digitalWrite(D0,HIGH);
digitalWrite(D1,HIGH);
digitalWrite(D2,HIGH);
}
else
{
digitalWrite(D0,LOW);
digitalWrite(D1,LOW);
digitalWrite(D2,LOW);
}
}
void loop()
{
Blynk.run();
LED();
}
Is that the full code?
nope, i didn’t include the void setup…
Please format code correctly by surrounding it like:
``` code ```
trouble formatting it… sorry
Please edit the post.