Levi Vohland / Mbed 2 deprecated mbed_AFDAU

Dependencies:   mbed

main.cpp

Committer:
VohlandL
Date:
2018-12-10
Revision:
0:341db01762fe
Child:
1:6cb1e26cf1ff

File content as of revision 0:341db01762fe:

#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);
        }
    }
}