I am currently planning a curriculum to teach children about building with microcontrollers and coding. So far, they have learnt basic circuit building and simple coding (Enough to build a light following robot on their own). I want to teach them about how computers communicate by having them build an 8-bit communication connection between the Raspberry Pi and the Arduino.
I have built a 2-bit communication connection by having the Raspberry Pi read 2 pins on the Arduino. Im using pins 8 and 9. The problem is the transition time of the pins. For example, if both pins were off and I want both pins to be on, since I turn them on one at a time, there will be a period when one pin is on and the other is off. This causes the information sent to the Pi to be wrong during this period. I wasn’t expecting this period to be as long as it is. My current solution is to have a 3rd pin that lets the Pi know that the configuration is ready. I use pin 2 for this. Basically immediately after digital write, I have a delay that lets the pins transition, then turn on pin 2, delay a little more, turn pin 2 off and delay a little more. But this solution inevitably slows down the communication speed by at least half a second. Is there a better solution that doesn’t slow down the communication speed as much?