Two-Way (Duplex) Serial Communication
Original hardware set up (this is wrong…again)!
The code was relatively easy again, and everything seemed to “work” without real problems, but when testing everything out, it wasn’t really working the way I thought it would. It was a lot shakier and turned on and off more than I thought it would.
Looking into the console log for p5, everything seemed to work, there were values that would increase and decrease in response to the potentiometers.
But then checking the values in serial monitor in Arduino, there was where we found the problem.
In the serial log, we saw that even without pushing the red button, the values were jumping from 1 to 0 to 1, which meant that the circle was turning on and off on its own, which was the reason for the intense jittering. Since everything was reading in p5 and Arduino, it seemed like there might be something wrong with the circuit board, so we looked again.
If you look at the schematic images above, the potentiometers, LEDs and buttons all have a connection to power, a resistor, and a connection to the microcontroller, except the first brown button schematic, which only has a connection (1) button to a resistor to ground and (2) button to digital input, and is missing a connection to power.
Once this connection was made (see yellow power wire connecting button to power rail), and resistor and ground being connected together to ground rail, the serial monitor displayed a steady read of 0 until the button was pushed and then read 1, so we have a successful two way communication.
Because the circle isn’t turning on and off by itself anymore, the circle movements are a lot more stable, but there might always be a certain amount of jitter.