Transfer Number Protocol with GPIO

I have connect hardware I use to Arduino in order to use Arudino sound shield.
I've connect it using 4 GPIO cables. I've also wrote small application that set the respected lines to 0 or 1 based on number between 0-15 and wrote Arduino app that read those lines and reassemble them into single number.
Everything works great but now I need to pass a number between 1 and 400 :slight_smile:

I'll try to see if I have 9 free GPIO ports to connect to, but if I don't I need to pass the number using the exist 4 cables.

Does anyone have any suggestion of how to pass the numbers. The major problem is that my hardware and the Arduino share no timing so I need a protocol that will be reliable enough, and not to slow.

Thank you,
Ido,

Does anyone have any suggestion of how to pass the numbers. The major problem is that my hardware and the Arduino share no timing so I need a protocol that will be reliable enough, and not to slow.

You could send the number as a string, ensuring that the string ALWAYS contained 3 characters, with leading 0's as needed.

Then, with suitable timing, you could read the 4 pins to get '4', then '0', then '0', and store the values in a NULL terminated char array, as "4", "40", and then "400", and then pass the array to atoi() to get 400.

If you are not using the analog pins as analog pins, they can be used as digital pins.