Hello
in a skecht I use the attachinterrupt to activate the buzzer and led.
If in this I assign a value to a variable
void blinkZ2 ()
{
Serial.println ("Zone2");
delayMicroseconds (1000000);
AStatoZ2 = 1;
}
must it necessarily be declared volatile (volatile int AStatoZ2 = 0)?
If I check it volatile it gives me the following error
ERROR MSG
../wiring/inc/spark_wiring_cloud.h:121:24: note: candidate: 'static bool CloudClass :: _ variable (const char *, const int32_t &)'
121 | static inline bool _variable (const char * varKey, const int32_t & var)
due to these lines in the void loop:
if (AStatoZ2 == 1) {digitalWrite (LedZona2, HIGH);}
char dataZ2 [5];
snprintf (dataZ2, sizeof (dataZ2), "% i", AStatoZ2);
Particle.publish ("Status Z2:", dataZ2, PRIVATE, NO_ACK);
Second question as highlighted use delayMicroseconds there is an alternative to this delay since in the reference they recommend not to have long delay values .
Best
Valentino