Saide Mathis
/
TEST_DEBUG_LED
c
Diff: main.cpp
- Revision:
- 0:bdb6d686a9cf
- Child:
- 1:0b65d1f1d8f7
diff -r 000000000000 -r bdb6d686a9cf main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Feb 12 08:49:58 2020 +0000 @@ -0,0 +1,36 @@ +#include "mbed.h" + + +I2C LED (p9,p10); +const int addr = 0x7e; +int main() { + char cmd[2]; + // LED.write(0x7e); + + while(1) { + /*cmd[0] = 0x4; // pointer to command register + cmd[1] = 0x0; // Start ranging, results in cm + LED.write(addr, cmd, 2); // Send command string + wait(0.07); */ + + cmd[0] = 0xAA; + LED.write(addr, cmd, 1); + LED.read(addr, cmd, 2); // read the two-byte echo result + //LED.write(0x7e, &A,1); + + /*wait(0.5); + + cmd[0] = 0xff; + LED.write(addr, cmd, 1); + LED.read(addr, cmd, 2); // read the two-byte echo result*/ + + wait(0.5) ; + + cmd[0] = 0x55; + LED.write(addr, cmd, 1); + LED.read(addr, cmd, 2); // read the two-byte echo result + + wait(0.5) ; + + } +}