![]() Second: master requests response: // step 4: request reading from sensor 10 - 50 ms to process requests but in the example I'm refering to master doesn't delay read) Wire.endTransmission() // stop transmitting ![]() Wire.write(byte(0x02)) // sets register pointer to echo #1 register (0x02) Wire.beginTransmission(112) // transmit to device #112 In a nutshell:įirst: master requests a function to measure distance: // step 3: instruct sensor to return a particular echo reading Plese refer to the range finder example on arduino page. I2C communication is based on requestFunction-(wait)-requestResponse sequence controlled by the master. Slave should provide proper answer to a given request eliminating the problem of data interpretation. Why? Because it's master which should decide when to request values and properly decode the request. ![]() Slave should read values from analog inputs and master should request them. Unfortunately Examples for I2C master and slave included in Arduino IDE are IMO too limited to provide clear guidance on this matter.įirst of all in your examples the master and slaves roles are exchanged and should be switched. Ahh what we have here is a basic question on how to design I2C communication. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |