how can I give Particle.function() an integer value instead of a String ?
Thanks
how can I give Particle.function() an integer value instead of a String ?
Thanks
You canβt. But you can use this:
https://docs.particle.io/reference/device-os/firmware/photon/#toint-
You can convert the arguments of the function to an int.
Example:
int myFunction(const char* args) {
int myInt = atoi(args); // Convert args to an integer
Serial.println(myInt*10); // Multiply myInt by 10 and print it to Serial
return myInt; // return to see if args converted to the expected integer
}
In setup()
you would have something like this:
Particle.function("myFunction", myFunction);
Itβs good practice to use char arrays instead of String
whenever possible.