Master Send Data to Arduino UNO
Materials
AMB82-mini x 1
Arduino UNO x 1
Example
I2C Introduction
There are two roles in the operation of I2C, one is “master”, the other is “slave”. Only one master is allowed and can be connected to many slaves. Each slave has its unique address, which is used in the communication between master and the slave. I2C uses two pins, one is for data transmission (SDA), the other is for the clock (SCL). Master uses the SCL to inform slave of the upcoming data transmission, and the data is transmitted through SDA. The I2C example was named “Wire” in the Arduino example.
Introduction
In this example, we use Ameba as the I2C master writer, and use Arduino as the I2C slave receiver.
When the I2C slave receives string sent from I2C master, it prints the received string.
Procedure
Setting up Arduino Uno to be I2C Slave
Then click “Sketch” -> “Upload” to compile and upload the example to Arduino Uno.
Setting up Ameba to be I2C Master
Wiring
AMB82 MINI wiring diagram:
Code Reference
Wire.begin()
/ Wire.begin(address)
to join the I2C bus as a master or slave, in the Master case the address is not required.Wire.beginTransmission(address)
to begin a transmission to the I2C slave with the given address:Wire.write()
to send data, and finally use Wire.endTransmission()
to end a transmission to a Slave and transmits the bytes that were queued: