![]() ![]() Then, using the function “write()”, some characters containing some letters signs are sent, and then, a byte of the actual data is sent. Then, using the function “beginTransmission(8)”, the address of the slave is entered and I2C communication is started for data transfer.In the main loop, the analog input is stored in the variable “value” and converted to the range of 0-255.We start working with library using the “begin()” function.The following points are worth mentioning regarding the code above: We want to send the value of the potentiometer on the master side to the slave and receive a byte of the potentiometer data by the slave, display it on the Serial Monitor and control the brightness of the LED with it. onRequest(): This is defined as a function by the slave and is called when data is requested by the master.onReceive(): This is defined as a function by the slave and is called when data is received from the master.setClock(): This is used by the master to set the clock frequency. ![]() ![]() read(): The function for reading a byte of data from the I2C bus.available(): Both the master and the slave use this function to calculate the number of bytes received (by the “read()” function).write(): Both the master and the slave use this function to send data to the I2C bus. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |