Week 12, still in lockdown, so for this week's assignment I had to work with the Arduino Uno boards that are in my "salvation" kit. I decide to try the I2C protocol so, firts things first I studied how the communication works looking through the Arduino Wire Library which also gave me an overview of the commands:
After the overview I looked into the two arduino tutorial on maste/slave coding:
- Master Writer/Slave Receiver
- Master Reader/Slave Sender
So next I followed this tutorial and I started making the connections between the two boards:
This is the first code I found on the tutorial, and it's the one for the master:
This is the code for the slave board:
At first I had a bit of trouble because the code worked entirely on the master board, the slave had no functions at all. I had followed the tutorial, which was very clear and I didn't understand why it didn't work properly. So I went back on the tutorial and read the whole thing again to be sure I didn't miss a part untill I saw this:
So I had to find a way to upload the codes separately. First thing that came up to my mind was when in Electronics design week I had to choose a programmer and a programmee from the IDE Arduino so I selected "Arduino ad ISP" as a programmer but that obviously didn't work so after some advise from my collegues and instructor I realized I just had to connect and upload one board at the time. So first I connected one board, uploaded the master code and unplugged it, then I connected the other board, uploaded the slave code and unplugged it. Then I connected the master board through the USB port and made again the connection with the slave board using the jumpers. As soon as it received current everything worked fine. So here it is: