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.
Diff: main.cpp
- Revision:
- 0:341db01762fe
- Child:
- 1:6cb1e26cf1ff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Dec 10 11:13:56 2018 +0000
@@ -0,0 +1,25 @@
+#include "mbed.h"
+
+// assign I2C pins
+int I2C_adr = 0x27 << 1;
+
+// initialise
+char C39_data[3] = {0, 255, 255};
+int instWeight = 0;
+
+//Set up serial and I2C connections
+Serial pc(USBTX, USBRX);
+I2C i2c(p9, p10);
+
+int main() {
+
+ while(1){
+ i2c.read(I2C_adr, C39_data, 3);
+
+ if (C39_data[1] < 255) {
+ instWeight = C39_data[1] << 8;
+ instWeight = instWeight | C39_data[2];
+ pc.printf("%d\n",instWeight);
+ }
+ }
+}