Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- hisyamfs
- Date:
- 2019-01-29
- Revision:
- 0:5cf249ca41f0
- Child:
- 1:4100c0aeb0d7
File content as of revision 0:5cf249ca41f0:
#include "mbed.h"
#define I2C_ADDR 0xC0 << 1
#define WR 0
#define RD 1
I2C cmps12(D14, D15); //sda, scl
DigitalOut led(LED1);
Serial pc(USBTX, USBRX);
int main()
{
led = 0;
char data[2];
data[0] = 0;
pc.printf("Started scanning\n");
int nack = 1;
for (char addr=0; addr < 255; addr++)
{
nack = cmps12.write(addr, data, 1);
if (!nack) {
led = 1;
pc.printf("Found at %X\n", addr);
}
else {
led = 0;
}
}
pc.printf("FINISHED \n");
while(1) {}
}