
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
Diff: PCF8574.cpp
- Revision:
- 2:835c883d81b0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PCF8574.cpp Fri Dec 15 19:40:41 2017 +0000 @@ -0,0 +1,28 @@ +#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); +} +