I have written this snippet of code using the lambda function
//CODE//
void SquareWave(int pin,
unsigned long offtime,
unsigned long ontime,
int Vpinled,
float flow1,
float flow2)
{
analogWrite(pin, flow1);
Blynk.virtualWrite(Vpinled, 0);
timer.setTimeout(ontime, []()
{
analogWrite(pin, flow2);
Blynk.virtualWrite(Vpinled, 255);
});
}
//ERROR MESSAGE//
Arduino: 1.8.9 (Windows 10), Board: "LOLIN(WEMOS) D1 R2 & mini, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 921600"
C:\Users\proie\Dropbox\ARDUINO\arduino 1.8.9\AQUART_BLYNK_COMPUTER\WAVEMAKER_PLUGBAR\WAVEMAKER_PLUGBAR.ino:55:33: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
SNTPtime NTPch("uk.pool.ntp.org");
^
C:\Users\proie\Dropbox\ARDUINO\arduino 1.8.9\AQUART_BLYNK_COMPUTER\WAVEMAKER_PLUGBAR\FUNCTION.ino: In lambda function:
FUNCTION:629:17: error: 'pin' is not captured
analogWrite(pin, flow2);
^
FUNCTION:629:22: error: 'flow2' is not captured
analogWrite(pin, flow2);
^
FUNCTION:630:24: error: 'Vpinled' is not captured
Blynk.virtualWrite(Vpinled, 255);
^
exit status 1
'pin' is not captured
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Does anybody know why āpin is not capturedā?