I am new to electronics, circuits, etc. Currently I am reading I2C and synchronous serial communications. As I understand, two devices must be connected to the same CLOCK wire so that the slave knows at which rate to interpret data because it might not have an internal clock. Now, I wanted to see how fast SCL pin on Arduino Uno oscillates by connecting a LED to it and GND and expected the LED to blink fast. Of course, as I believe, I attenuated the frequency to 1 by using Wire.h library and calling
Wire.setClock(1);
as it is said here. The LED still didn't blink as I expected - once a second. What is wrong? How does SCL behave actually? Does it oscillate from 0V to 5V periodically or I must manually do this in the code?
EDIT
The complete sketch was as follows
#include <Wire.h>
void setup() {
// put your setup code here, to run once:
Wire.setClock(1);
}
void loop() {
// put your main code here, to run repeatedly:
}
EDIT 2
I built a circuit. The LED is turned on but it doesn't blink. I also tried changing the frequency in the code from 1 to different values up to 100000.
EDIT 3
It blinks! But I am not sure is it actually SCL making it blink. I added Wire.begin()
in setup()
and started together with ending a transmission in the loop()
. But it doesn't react to changes in setClock(frequency)
. Also I tried to put a delay or send long random text with Wire.write()
between Wire.beginTransmission(0xA3)
and Wire.endTransmission()
. Then it just blinks once (maybe multiple times but fast) in the beginning and then stops blinking just being on. The complete code is
#include <Wire.h>
void setup() {
// put your setup code here, to run once:
Wire.setClock(32000);
Wire.begin();
}
void loop() {
// put your main code here, to run repeatedly:
Wire.beginTransmission(0xA3); //arbitrary address
Wire.endTransmission();
}