i2c scanner like arduino i2c sample.

Dependencies:   mbed

main.cpp

Committer:
netwing
Date:
2016-06-28
Revision:
0:d58e47b3cc7e

File content as of revision 0:d58e47b3cc7e:

#include "mbed.h"
I2C i2c(D14, D15);        // sda, scl
Serial pc(USBTX, USBRX); // tx, rx

int main()
{
    pc.printf("RUN\r\n");
    for(int i = 0; i < 128 ; i++) {
        i2c.start();
        if(i2c.write(i << 1)) pc.printf("0x%x ACK \r\n",i); // Send command string
        i2c.stop();
    }
}