Hello! I have a problem. I connected an ESP8266 to the Arduino MEGA communications pins 18 and 19 and I want to control an LED using interrupt from pin 2 in witch i connected a sound sensor on RISING from 0 to 1, the ESP connects the Arduino with BLYNK where is a button that goes high and low according to the sound sensor and a boolean variable also when i pres the button the led goes HIGH or LOW it works the first time but after the interrupt is called The esp stop comunicating and BLYNK says the device is disconected.
Here is the code without the libraries and other stuf part , because there is a larger code:
const int led_cam = 4;
const int soundSensor_cam = 2;
volatile boolean LEDStatus_cam = false;
void setup()
{
attachInterrupt(digitalPinToInterrupt(soundSensor_cam), lumina_camera, RISING);
}
void lumina_camera()
{
if (LEDStatus_cam == false)
{
digitalWrite(led_cam, HIGH);
Blynk.virtualWrite(V0, HIGH);
LEDStatus_cam = true;
}
else
{
digitalWrite(led_cam, LOW);
Blynk.virtualWrite(V0, LOW);
LEDStatus_cam = false;
}
}
/////////////////////////////////
BLYNK_WRITE(V0)
{
if (param.asInt() == HIGH)
{
digitalWrite(led_cam, HIGH);
}
else
{
digitalWrite(led_cam, LOW);
}
}
///////////////////////////////////