- This topic has 1 reply, 1 voice, and was last updated 3 years, 6 months ago by .
- You must be logged in to reply to this topic.
Home › Forums › The libraries hosted on the site › PCF8574 i2c digital I/O expander › pcf8574 ReadAll in low memory compare to single value byte
Hello Everyone,
I have a byte field that I need to compare with ReadAll without using low memory,
After several attempts I couldn’t, how to compare
PCF8574 :: DigitalInput di = pcf85741.digitalReadAll ();
with byte value?
ex:
byte valor = 220;
if(valor == PCF8574 :: DigitalInput di = pcf85741.digitalReadAll ());
Thank you
Hi Fernando,
you must reduce the DigitalInput object to a byte like so:
byte byteValReadAll = 0;
void setVal(uint8_t pin, uint8_t value){
if (value==HIGH){
byteValReadAll = byteValReadAll | bit(pin);
}else{
byteValReadAll = byteValReadAll & ~bit(pin);
}
}
[...]
setVal(P0, digitalInput.p0);
setVal(P1, digitalInput.p1);
setVal(P2, digitalInput.p2);
setVal(P3, digitalInput.p3);
setVal(P4, digitalInput.p4);
setVal(P5, digitalInput.p5);
setVal(P6, digitalInput.p6);
setVal(P7, digitalInput.p7);
Serial.println(byteValReadAll, BIN);
[...]
Bye Renzo
More
3D Printer 3D printer upgrade ABB Arduino Arduino IDE Arduino SAMD boards Aurora AWS CNC Cyclone PCB Factory Cyclone PCB Factory how to build It Display DynamoDB E32 E70 EByte esp01 esp32 esp8266 File System Firmware i2c Library LoRa MicroPython Milling PCB My PCB Networking PCB pinout Power saving Programming board Raspberry Pi REST API RF rp2040 SD Card Sensors Sleep and Wake UP SPI STM32 Tutorial Web Server Wemos D1 mini WiFi