This is a remote control tester, it uses a CNC, Ethernet Communication with a JAVAFX interface and a PLC in order to control some valves.

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of CNC_CONTROLLER by Lahis Almeida

PCF8574.cpp

Committer:
kevencastro7
Date:
2017-12-15
Revision:
2:835c883d81b0

File content as of revision 2:835c883d81b0:

#include "PCF8574.h"
#include "mbed.h"

PCF8574::PCF8574(PinName sda, PinName scl, int address)
        : _i2c(sda, scl) {
    _address = address;
}

int PCF8574::read(int port) {
    char foo[1];
    int num,r,i=0;
    int bin[8];
    _i2c.read(_address, foo, 1);
    num = foo[0];
     while(num!=0){
        r = num%2;
        bin[i++] = r;
        num /= 2;
    }
    return(bin[port]);
}

void PCF8574::write(int data) {
    char foo[1];
    foo[0] = data;
    _i2c.write(_address, foo, 1);
}