I'm trying to create a library for a group of Arduino's set up in parallel controlled thru a GUI via the serial port. In order to exit from the current Arduino you press an exit button on the GUI. This sends out a letter "z" to the Arduino. When the Arduino receives this letter it puts a 500 millisecond pulse on pin 5. The Control Arduino senses this pulse and disconnects the current Arduino letting the user choose another Arduino. The code works fine but I'd like to put it in a Library rather then typing it out for every Arduino. I've looked up how to create a library but am totally confused.
The .cpp file is for the code? What do I put in the .h file? Here is the code Id like to put in the library.
First you have to decide "WHAT" you want to put in the library. Start with a clear documentation what functionality you want to have separated in a reusable library.
Is it the serial read?
Is it the pulsing of the pin*)?
Both together? Then you should start and put it in a function first and just call that function.
if you tell more about what you want to achieve, we can give better hints.
p.s.: *) why do you block your code with a delay? why not a non-blocking variant with millis?