The "1" means the number of bytes send in the complete command. See the next sample code when using a ds1621. Its initialize the registers at starrt.
addr = 0x90; // adres van ds1621
cmd[0] = 0xac; // access config prot
cmd[1] = 0x02; // output pol high , continu conv
i2c.write(addr, cmd, 2); // Send command string
i2c.stop();
wait(0.07);
addr = 0x90; // adres van ds1621
cmd[0] = 0xa1; // access TH
cmd[1] = 0x18; // set TH = 24 graden
cmd[2] = 0x00; // set TH = 00
i2c.write(addr, cmd, 3); // Send command string
i2c.stop();
wait(0.07);
addr = 0x90; // adres van ds1621
cmd[0] = 0xa2; // access TL
cmd[1] = 0x16; // set TL = 22 graden
cmd[2] = 0x00; // set TL = 00
i2c.write(addr, cmd, 3); // Send command string
i2c.stop();
wait(0.07);
addr = 0x90; // adres van ds1621
cmd[0] = 0xee; // start conv t
i2c.write(addr, cmd, 1); // Send command string
i2c.stop();
Hello,
Giving the information that i am new to the C language, i want to use my mbed to drive 8 led's on the I²C bus by using a PCF8574AP. This becouse i am using the I²C bus in my dissertation for my high school studies and i want to get used with it. Previously i tried it with the library for the PCF8574, but it did not work (the led's where glowing very faintly. So i wrote my own program, very simple : turn all the led's on, and turn them back off, so here it is:
#include "mbed.h"
I2C i2c(p28, p27);
int main() {
while (1) {
void start(void); //start condition
i2c.write(0x40); //write adress
i2c.write(0xf); //write data
void stop(void) ; //stop condition
wait(1);
void start(void); //start condition
i2c.write(0x40); //write adress
i2c.write(0x0); //write data
void stop(void); //stop condition
wait(1);
}
}
The compiler is not giving any errors/warnings, but the led's are still just glowing faintly and do not seem to be affected by my code.
All help is welcome, thanks in advance :)