I am trying to send an email when either one digital pin value is changed. (Even Low to High or reverse)
However, the below 1st code is successful but 2nd code is unsuccessful
2nd code cannot trigger the email normally when D0 and D1 either Low or High
Because I would like to reduce the code as I can, I would use all pins for the ESP8266 board.
Void email()
{
int content = digitalread(D0)
if (content == HIGH)
{
String body = "XXX";
Blynk.email(email address, "Subject", body);
}
else
{
String body = "YYY";
Blynk.email(email address, "Subject1", body);
}
}
Void email1()
{
int content1 = digitalread(D1)
if (content1 == HIGH)
{
String body = "WWW";
Blynk.email(email address, "Subject", body);
}
else
{
String body = "ZZZ";
Blynk.email(email address, "Subject1", body);
}
}
void setup()
{
pinMode(D0, INPUT);
pinMode(D1, INPUT);
attachInterrupt(digitalPinToInterrupt(D0), email, CHANGE);
attachInterrupt(digitalPinToInterrupt(D1), email1, CHANGE);
}
Void email()
{
int content = digitalread(D0)
int content1 = digitalread(D1)
if (content == HIGH)
{
String body = "XXX";
Blynk.email(email address, "Subject", body);
}
else
{
String body = "YYY";
Blynk.email(email address, "Subject1", body);
}
if (content1 == HIGH)
{
String body = "WWW";
Blynk.email(email address, "Subject", body);
}
else
{
String body = "ZZZ";
Blynk.email(email address, "Subject1", body);
}
}
void setup()
{
pinMode(D0, INPUT);
pinMode(D1, INPUT);
attachInterrupt(digitalPinToInterrupt(D0), email, CHANGE);
attachInterrupt(digitalPinToInterrupt(D1), email, CHANGE);
}
However, my idea is like that, should I better to use virtual pins to store the email content?