Read a number from an address on the I2C bus.
If your board has pins that say SDA and SCL, then you can read numbers from other chips that are not on your board. The SDA and SCL pins connect to other chips (ICs) that also have these same pins. This connection is called I2C. It only needs two wires to read or write a number. As you can guess, one wire is for SDA and the other is for SCL.
The wires, and the signals that go through them, together are called a bus. An I2C connection is an I2C bus.
You might know that storing a number in electronics takes several bits of digital information that exist all at one time (a combination of many high and low voltages inside a chip). Since the I2C bus has only two wires, a number moves through one of the wires just one bit at a time. The bits of the number are short pulses of high and low voltage on the SDA wire. The SCL wire lets one chip tell another chip when the next bit of the number is on the SDA wire.
To keep things simple, the I2C bus lets many chips connect to the same wires. Nice, because it could get messy if each chip couldn’t share the same wires. This is like pretending the chips are houses on a street. The street is the bus connected to the chips, the houses. We know that a house on a street usually has an address. Same thing with chips on a bus. Without an address, a number would move on the bus but the chips waiting for input wouldn’t know who’s supposed to receive it.
The chips on your bus can have address numbers that are between 8
and 123
. Make sure that all of the chips are using a different number so they respond to their own address.
8
and 123
that is the address of a chip on the I2C bus.Int8LE
.true
or false
, to say if you want to read again right away.false
if you wait for a while before reading from, or writing to, the bus again.Connect a temperature sensor on a breadboard to the SDA and SCL pins on your board. Set your sensor to respond to address 24
. Every 30 seconds, read the temperature from the sensor and write it as Fahrenheit to the serial port.
Write a number to an address on the I2C bus.
If your board has pins that say SDA and SCL, then you can write numbers to other chips that are not on your board. The SDA and SCL pins connect to other chips (ICs) that also have these same pins. This connection is called I2C. It only needs two wires to read or write a number. As you can guess, one wire is for SDA and the other is for SCL.
The wires, and the signals that go through them, together are called a bus. An I2C connection is an I2C bus.
You might know that storing a number in electronics takes several bits of digital information that exist all at one time (a combination of many high and low voltages inside a chip). Since the I2C bus has only two wires, a number moves through one of the wires just one bit at a time. The bits of the number are short pulses of high and low voltage on the SDA wire. The SCL wire lets one chip tell another chip when the next bit of the number is on the SDA wire.
To keep things simple, the I2C bus lets many chips connect to the same wires. Nice, because it could get messy if each chip couldn’t share the same wires. This is like pretending the chips are houses on a street. The street is the bus connected to the chips, the houses. We know that a house on a street usually has an address. Same thing with chips on a bus. Without an address, a number would move on the bus but the chips waiting for input wouldn’t know who’s supposed to receive it.
The chips on your bus can have address numbers that are between 8
and 123
. Make sure that all of the chips are using a different number so they respond to their own address.
8
and 123
that is the address of a chip on the I2C bus.Int8LE
.true
or false
, to say if you want to read again right away.false
if you wait for a while before reading from, or writing to, the bus again.Connect a 12-bit digital-to-analog converter (DAC) on a breadboard to the SDA and SCLpins on your board. Set your DAC to respond to address 99
. Write numbers to the DAC to have it make a sawtooth wave about every second.