Triggering functions
Sometimes, exchanging the data is not enough. In more complex projects there are events that occurs from both sides, especially triggering some event in arduino from html button. It's great to know that Involt cares about simplicity of such events.
Triggering from app to device
For example, use HTML element to send its value and trigger some event in Arduino sketch:
void loop(){
involtReceive();
if(fname == "involt"){
doSomething...
};
fname = ""; //clear the name to prevent from repeating the function each time
}...
For sending only the function use button-cta.
JQuery method to send function:
Pure JS solution:
Triggering from device to app
Adding this function to sketch will send name of function to app.
It's done with declaring the function in involtFunction JS object. Include the custom script in new file and attach it to end of HTML head section.
//do something when function "involt" was triggered from device...
};Listen for received pin value (in app)
Use it to call function each time when app receives value from certain pin. The index, value are related to received pin data.
//do something when received value from pin A0...
};Be aware of using it for real time update, especially when manipulating the DOM. Instead use interval based update.