Sub Process_Globals
Private SDApin As Byte
Private SCLpin As Byte
Private I2Caddress As Byte
End Sub
public Sub Begin(SDAp As Byte, SCLp As Byte, Address As Byte)
SDApin = SDAp
SCLpin = SCLp
I2Caddress = Address
RunNative("pcfsetup",Null)
Delay(200)
RunNative("play",Null)
End Sub
#IF C
#include <PCF8574.h>
// Instantiate Wire for generic use at 400kHz
TwoWire I2Cone = TwoWire(0);
// Instantiate Wire for generic use at 100kHz
TwoWire I2Ctwo = TwoWire(1);
//PCF8574 pcf(&I2Ctwo, b4r_stn::_i2caddress); // did not work, how can I pass address to this line?
PCF8574 pcf(&I2Ctwo, 0x27); //works OK, address is hard codded
void pcfsetup(B4R::Object* o) {
I2Ctwo.begin(b4r_stn::_sdapin, b4r_stn::_sclpin,100000U); // SDA pin, SCL pin, 100kHz frequency
pcf.pinMode(P0, OUTPUT);
bool b = pcf.begin();
}
void play(B4R::Object* o)
{
pcf.digitalWrite(P0, HIGH);
delay(2000);
pcf.digitalWrite(P0, LOW);
}
#End If