WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

writeRegister

Performs a complete communication session with a device to write to a value to a single register.
Returns TRUE if successful or FALSE if there was an error.
Syntax
I2cDevice. writeRegister(reg,value)
Where I2cDevice is the name you have given to the device in Project Designer.
Parameters
TypeNameDescription
'reg'
The register number.
'value'
The value to be written.
Returns
boolean
Note
This is the same as the following pseudo code:
// Connect in write mode
i2cStart( WRITE );
// Write the start register
i2cPut( reg );
// Write the data value
i2cPut( value );
// Hang up
i2cStop();
Example
Assuming you have created a 'Generic I2C Device' in Project Designer called myDevice and you want to set register 10 to the value 56 then you would use:
if( myDevice.writeRegister(10, 56) ){
    // ok
}else{
    // Communication failed
}

 

 

Valid XHTML 1.0 Transitional