Off the shelf Part 3 - Getting the I2C to talk
there are several simple examples of Raspberry Pi to Arduino I2C on the web
In studying them, I'd selected on in particular example that was a best fit:
- demonstrated both data read & write
- used a recognized standard library
- coding was straightforward, easy to read
none of the examples I found exchanged multiple bytes.
Like many examples on the web, even a proven code example need some extra love.
This program has the user enter a value into the Raspberry Pi Python window, the Arduino reads the value and sends it back.
In this case, the quotation marks didn't translate on copy, and the Raspberry Pi code lost indent format - no biggie to fix that part
However on RUN, the Python Shell complained the keyboard input number was not an integer but a string.
WELLL.......... I'm not so smart, so a line of code is added to convert string to a byte, thats what the code is reading and writing.
Now the VOODOO , Python tells me again an integer is required to write a byte.
OK, I cave , add a line to converter a string to integer and behold the data comes to life and the example
code is working.
However , also take note that as integer values bigger than a byte are entered, they are truncated to a byte.
its working now
The next STEP is to have the Arduino send multiple bytes to the Raspberry Pi using I2C.
BYTE ME !!
- More investigation for writing multiple bytes from the Arduino to RPi, several tries , it is not working yet.
- The Raspberry Pi byte array always displays the value of array  in all locations of the byte array. See Screen 4
- Troubleshooting the Arduino code, the 5 bytes of data, 2 bytes for the up/dwn joystick position, 2 bytes for the
left/right joystick , and an extra byte for later use, is being loaded into a byte matrix correctly. see Screen 5
The scheme shown in screen 5 is in the main loop.
- maybe the array values cant be seen by the void SendData() function, so all the array code and reading of analog inputs
were moved to void SendData() - see Screen 6 - it made no difference
Next up, a gris-gris and a good Python potion for the next attempt of.........send me some bytes from the Nano.