I'm taking Clock data(SCL) from A5 and SDA from A4 port in Arduino UNO board. The code below is used to illustrate 8 bit signal on oscilloscope. The problem is that the 8 bit signal is not totally square wave and ACK bit is high. Please help me.
#include <Wire.h>
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
}
byte x = 0;
void loop()
{
Wire.beginTransmission(170); // transmit to device #4
Wire.write(0x07); // sends five bytes
Wire.endTransmission(); // stop transmitting
x++; // increment value
if (x == 127) { // if reached 64th position (max)
x = 0; // start over from lowest value
}
delay(10);
}
Hi, @oyunerdene102521
Can you please draw a simple circuit showing your UNO, Scope and connections including resistors?
An image of a hand drawn diagram would be fine.
You are using the address 170 (0xAA, 0b10101010) which gets truncated to 0x2A (0b0101010) because the Wire library expects 7-bit addresses. The address then gets shifted left one bit to make room for the Read/Write bit. Write is 0 so the address byte being sent is: 0b01010100. That looks like what you have on the scope.
I think the 9th clock rising edge is where the bus master samples the ACK signal. Since there is no device at address 0x2A there is no ACK.