Trying to study the Wire library, I read some info taken from here.
As you all know, this really simple example changes the value of a AD5171 digital potentiometer via I2C. Written by Nicholas Zambetti and Shawn Bonkowski, demonstrates use of the Wire library.
I just copied and adapted the code below from the example. I am an experienced assembler and C/C++ programmer and hardware developer/designer.
Although several I2C devices like DS3231 RTC, etc. work fine using standard Arduino libraries, the mentioned example doesn't work for me in my working NANO board.
What am I doing wrong, please?
This code should transmit:
1 - first the I2C protocol device address - Start / 8 + 1bits
2 - 1 test instruction data byte
3 - 1 variable test byte constantly incremented
4 - I2C Stop condition
The only byte I can see in my oscilloscope is just the first one (picture attached). The 2 data bytes are not being transmited. If I reduce the transmission to just the step (2) instruction single data byte, same result is shown.
#include <Wire.h>
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
}
byte val = 0;
void loop()
{
Wire.beginTransmission(44); // transmit to device #44 (0x2c)
Wire.write(byte(0x55)); // sends instruction byte
Wire.write(val++); // sends potentiometer value byte
Wire.endTransmission(); // stop transmitting
delay(50); // some time delay for my oscilloscope
}
Thank you in advance
Robert
