The objective of this project is simple: to understand how to transfer data from one Arduino board to another. In this case, the value to be transferred is coming from a potentiometer connected to the first Arduino board. If the value crosses a certain threshold, I will make the LED connected to the second Arduino board light up.
How to transfer values from one Arduino board to another?There are many different protocols which can be implemented to achieve the above mentioned objective.Here I am going to use the I2C protocol with master writer/slave receiver configuration.
What is I2C protocol?Simply put, in I2C communication protocol, you have two devices, a master and a slave, which are interconnected by two lines, a data line and a clock line.In Arduino Uno, the data line is Analog pin 4(A4) and clock line is Analog pin 5(A5). This however is different for different for different boards.
When the clock pin goes from low to high, one bit of data is transferred via the data pin.The slave board may then either send back data via the same data pin or perform a task(as in our case). The first eight bits, however, are reserved for the address of the slave Arduino board to which the master sends values.
How does the project work and what does it do?I use analog read in the master Arduino board, to get the value of a potentiometer connected to it. Then this value is transferred to the slave Arduino Board and if it is above a threshold, the LED connected to the slave Arduino lights up.
ConnectionsRefer to the uploaded Fritzing file for connections.
The two boards must have a common ground so connect the grounds from both the boards together.
ResultThere are many applications for I2C communication especially in the field of IoT (Internet of Things). Apart from that, this can also be used if one is running out of pins for a particular project and has multiple boards.
Comments