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
Diff: main.cpp
- Revision:
- 0:c123bc196680
- Child:
- 1:11ff92032e78
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Jan 15 15:37:09 2016 +0000
@@ -0,0 +1,69 @@
+#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 = 0x60;
+
+int main(){
+
+ char data_write[2];
+ char data_read[2];
+
+ led1 = 1;
+ led2 = 1;
+ led3 = 1;
+ led4 = 1;
+
+ data_write[0] = 0x00;
+ data_write[1] = 0x01;
+ //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();
+ } */
+}
\ No newline at end of file
