Hello Co-users of the MBED nxp,
I have the ambition to learn and comprehend C whilst building my first project.
My first experiments involves a I2C Ultrasonic Range Finder (SRF02).
The Example code works fine for me, but the problem is that i do not understand the whole code..
my isue is with this part:
int main() {
char cmd[2];
while(1) {
cmd[0] = 0x0; // pointer to command register
cmd[1] = 0x51; // Start ranging, results in cm
i2c.write(addr, cmd, 2); // Send command string
The line " char cmd[2];" does it create the two char's with cmd[0] and cmd[1]?
and witch one is send on the write command.? and the 2 that is send as data what does this do?
The rest of the code can be found here: http://mbed.org/handbook/I2C
These thing are propably basic C knowledge, but i can't find any clear explanation for this..
I hope one of you people will help me, Many thanks in advance.!
Ramsy.
Hello Co-users of the MBED nxp,
I have the ambition to learn and comprehend C whilst building my first project.
My first experiments involves a I2C Ultrasonic Range Finder (SRF02).
The Example code works fine for me, but the problem is that i do not understand the whole code..
my isue is with this part:
int main() {
char cmd[2];
while(1) {
cmd[0] = 0x0; // pointer to command register
cmd[1] = 0x51; // Start ranging, results in cm
i2c.write(addr, cmd, 2); // Send command string
The line " char cmd[2];" does it create the two char's with cmd[0] and cmd[1]?
and witch one is send on the write command.? and the 2 that is send as data what does this do?
The rest of the code can be found here: http://mbed.org/handbook/I2C
These thing are propably basic C knowledge, but i can't find any clear explanation for this..
I hope one of you people will help me, Many thanks in advance.!
Ramsy.