![](/media/cache/profiles/010d18a1aeff169f741b6fe97fdd6a1d.jpg.50x50_q85.jpg)
figuring this out...
Revision 2:ada8ecd122e4, committed 2014-05-28
- Comitter:
- ghostaudio
- Date:
- Wed May 28 14:59:12 2014 +0000
- Parent:
- 1:af525be281b0
- Commit message:
- getting closer;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed May 28 13:53:30 2014 +0000 +++ b/main.cpp Wed May 28 14:59:12 2014 +0000 @@ -1,7 +1,6 @@ #include "mbed.h" #include "VCNL40x0.h" -#define MUX 0x60 // 11100000 #define BAUD 115200 //const char chan0 = 0001; @@ -10,7 +9,7 @@ //const char chan3 = 1000; //const char all = 1111; -// unsigned char chan[] = {0001,0010,0100,1000,1111}; +const int MUX = 0x60; // 11100000 unsigned int sensors[4]; I2C i2c(p28, p27); @@ -18,23 +17,26 @@ DigitalOut mled0(LED1); // LED #1 Serial pc(USBTX, USBRX); // Tx, Rx USB transmission - int main() { unsigned int sensors[4]; - char chan[] = {0001,0010,0100,1000,1111}; + char chan[] = {0x01,0x02,0x04,0x08}; pc.baud(BAUD); // set USB speed (virtual COM port) for (int i = 0; i < 4; i++){ - - i2c.write(MUX,chan0, 2); + char port[2]; + port[0] = 0; + port[1] = chan[i]; + i2c.write(MUX,port, 2); VCNL40x0_Device.SetCurrent (20); // Set current to 200mA } while (1) { for (int i = 0; i < 4; i++){ - - i2c.write(MUX,chan[i]); + char port[2]; + port[0] = 0; + port[1] = chan[i]; + i2c.write(MUX,port, 2); mled0 = 1; // LED on VCNL40x0_Device.ReadProxiOnDemand (&sensors[i]); // read prox value on demand