First a quick thank you to all for helping me devote many happy hours to aggravating my myopia!
Presently, I only write sketches with void setup and void loop
but i see many sketches with other void functions. The reference page says:
The void keyword is used only in function declarations. It indicates that the function is expected to return no information to the function from which it was called.
I can't get my head around this. would somebody please tell me how to better use void to make my sketches work better. No information to the function...hmmmm.
For example I am experimenting with I2C networking. I have a master and slave Uno flashed with the sketches from an old posting ca. 2010: http://forum.arduino.cc/index.php?topic=48477.0 and it works.
Here is a part of the code from the Slave sender after the void loop closing brace:
// function that executes whenever data is requested by master
// this function is registered as an event, see setup()
void requestInt()
{
if (byteSending == 1) //send packet 1
{
toSend = Shift & mask;
..........and so on
I need to understand that using "void requestInt()" is better or needed...why cant it just live in the void loop? I know I am missing something big picture here.
I see that Up in set up there is this line
Wire.onRequest(requestInt); // register event
What is the significant of registering this event?
.. I think this is how the master/slave coordinate their coms but I'm stuck on what significantly effects when a void function is called. I'd better leave it that.
I have several years experience writing sketches that turn things on and off, PWM control of our sunroom vent and various outputs using feedback from temperature, pressure ...analog sensors. My biggest weakness (perhaps obviously) is thinking logically like a computer. Too much Guiness maybe?
cheers