User Tools

Site Tools


arduino_lib_dpi2ciopcf8574

Documentation Arduino base program code

DpI2CIOPCF8574 library

Description

DpI2CIOPCF8574 Arduino library provide function for using I/O pins on PCF8574(A) I2C port extender.

daince.net I/O Expansion board with PCF8574A.

Source code is provided as is, without any warranty.

Distributed under CC BY v 3.0

Functions

// inicialization
DpI2CIOPCF8574();
    
// set chip address, and read initial state on pins
// Addr - chip addres 0x20 - 0x27 for PCF8574 or  0x38 - 0x3F for PCF8574A
void begin(int Addr);
 
// set virtual pin for output or input
// use only for library prpouses
// pin - 0-7
// mode - from predefined value
//        PIN_MODE_INPUT  0x01
//        PIN_MODE_OUTPUT 0x00
void pinMode(byte pin, byte mode);
    
// read pin status from chip using internal buffer
// on same time chack for associate action to pin
void getInputStatus();
    
// write pin status to chip using internal buffer
void setOutputStatus();

// get value of virtual input pin (0 low, 1 high)
// pin - 0-7 (check if pin is set for input)
byte getInputPin(byte pin);
    
// set value of virtual output pin (0 low, 1 high)
// pin - 0-7 (check if pin is set for output)
// value - 0 low, 1 high (default)
void setOutputPin(byte pin, byte value = 1);

// toggle value of virtual output pin
// pin - 0-7 (check if pin is set for output)
void toggleOutputPin(byte pin);
    
// toggle value of all virtual output pins
void toggleOutput();
    
// set high (0) value to all virtual output pins
void setOutputHigh();
    
// set low (1) value to all virtual output pins
void setOutputLow();
    
// set Action function to be executed when virtual pin change status
// pin - 0-7
// userFunc - function name without attributes
// mode - type of change
//        ACTION_LOW     0x01
//        ACTION_HIGH    0x02
//        ACTION_CHANGE  0x03
//        ACTION_RISING  0x04
//        ACTION_FALLING 0x05 
void setActionFunction(byte pin, void (*userFunc)(void),byte mode);
 
// clear Action function from virtual pin ACTION_CLEAR   0x00
// pin - 0-7
void clearActionFunction(byte pin);

// clear Action function from all virtual pin ACTION_CLEAR   0x00
void clearActionAll();  

Contact

Author: Dubravko Penezic

Email: dpenezic@gmail.com

Version

Actual

History

V 1.0.0 , 06.03.2012

arduino_lib_dpi2ciopcf8574.txt · Last modified: by 127.0.0.1