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:
- maner1256
- Date:
- 2018-12-17
- Revision:
- 6:e83f444edda0
- Parent:
- 3:df6232c70efd
File content as of revision 6:e83f444edda0:
#include "mbed.h"
I2C i2cMaster(D14,D15);// SDA, SCL
DigitalIn mybutton(USER_BUTTON);
Serial pc(USBTX, USBRX);
char writeData[6];
int main() {
pc.baud(57600);
pc.printf("Starting I2CMaster\r\n");
i2cMaster.frequency(400000);
int address ;
writeData[0]=0x01;
writeData[1]=0x02;
writeData[2]=0x03;
writeData[3]=0x04;
writeData[4]=0x05;
writeData[5]=0x06;
while(1) {
int count = 0;
for (address=0; address<256; address+=2) {
if (!i2cMaster.write( address , NULL, 0)) { // 0 returned is ok
pc.printf("I2C address 0x%02X\r\n", address);
count++;
break;
}
pc.printf("I2C address 0x%02X\r\n", address);
if(mybutton == 0) {
i2cMaster.write(address,writeData,6);
pc.printf("i2cMaster Sent writeData[0] To 0x%02X \r\n", address);
wait(2);
}
}
}
}