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.
Dependencies: BLE_API mbed nRF51822 circular_buffer
main.cpp
- Committer:
- agufal
- Date:
- 2016-01-15
- Revision:
- 1:11ff92032e78
- Parent:
- 0:c123bc196680
- Child:
- 2:96f52163ca48
File content as of revision 1:11ff92032e78:
#include "mbed.h"
I2C i2c(p30, p7);
Serial pc(p9, p11);
//LEDS
DigitalOut led2(LED2);
DigitalOut led1(LED1);
DigitalOut led3(LED3);
DigitalOut led4(LED4);
const int addr = 0x38;
int main(){
char data_write[2];
//char data_read[2];
led1 = 1;
led2 = 1;
led3 = 1;
led4 = 1;
data_write[0] = 0x01;
data_write[1] = 0x00;
//i2c.start();
int status = i2c.write(addr,data_write, 2);
if (status != 0) { // Error
while (1) {
led4 = !led4;
wait(0.2);
}
}
/*while(1){
//i2c.start();
data_write[0] = 0x00;
i2c.write(addr, data_write, 1,1);
i2c.read(addr, data_read, 2,0);
int ch0 =(data_read[0]<<8) | data_read[1];
if (ch0 < 0x001FF){
led1 = 0;
led2 = 1;
led3 = 1;
}
else if (ch0 > 0x001FF && ch0 < 0x0FFF) {
led1 = 1;
led2 = 0;
led3 = 1;
}
else {
led1 = 1;
led2 = 1;
led3 = 0;
}
//pc.printf("channel 0: %x,%x \n", data_read[0], data_read[1]);
wait(0.5);
//i2c.stop();
} */
}
