Pcf8574 arduino library

mathertel/LiquidCrystal_PCF8574

Use Git or checkout with SVN using the web URL.

Work fast with our official CLI. Learn more.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Arduino Library for LiquidCrystal displays with I2C PCF8574 adapter

A library for driving LiquidCrystal displays (LCD) by using the I2C bus and an PCF8574 I2C adapter.

There are modules that can be soldered or stacked to the display that offers an I2C interface for communication instead of the 8+ digital lines that are used to send data to the display.

Most of these modules use the wiring that is supported by this library’s default configuration. If you use a module with a different wiring, you can use one of the class constructors which allow you to specify the pin assignments.

Changes Version 2.1.0 (2022-08-21)

Enables using a non-default i2c / TwoWire port for boards that support multiple ports.

Added example LCD_Burnin.ino showing how to transfer a 20 char and 4 lines buffer to a device all at once.

Thanks for additions from @uutzinger

Changes Version 2.0.0 (2022-05-26)

  • The interface was modified to use 8-bit datatypes as supported by the underling hardware.
  • A createChar version with PROGMEM character data for AVR processors was added.
  • A constructor with pin assignments was added to allow easy adoption to other wirings than the default.

Thanks for additions from @markisch.

About

A library for driving LiquidCrystal displays (LCD) by using the I2C bus and an PCF8574 I2C adapter.

Источник

RobTillaart/PCF8574

Use Git or checkout with SVN using the web URL.

Work fast with our official CLI. Learn more.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Arduino library for PCF8574 — 8 channel I2C IO expander

Related to the PCF8575 16 channel IO expander library https://github.com/RobTillaart/PCF8575

This library gives easy control over the 8 pins of a PCF8574 and PCF8574A chip. These chips are identical in behaviour although there are two distinct address ranges.

TYPE ADDRESS-RANGE notes
PCF8574 0x20 to 0x27 same range as PCF8575 !!
PCF8574A 0x38 to 0x3F

So you can connect up to 16 PCF8574 on one I2C bus, giving access to 16 x 8 = 128 IO lines. To maximize IO lines combine 8 x PCF8575 + 8 x PCF8574A giving 128 + 64 = 192 IO lines. Be sure to have a well dimensioned power supply.

The library allows to read and write both single pins or 8 pins at once. Furthermore some additional functions are implemented that are playful and useful.

Tested on UNO with PCF8574_performance showed that the PCF8574 still works at 500 KHz and failed at 600 KHz. These values are outside the specs of the datasheet so they are not recommended. However when performance is needed you can try to overclock the chip.

clock speed Read Write Notes
100000 236 240 spec datasheet
200000 132 140
300000 104 108
400000 96 96 max advised speed
500000 92 92 not recommended
600000 crash crash

PCF8574_INITIAL_VALUE is a define that can be set compile time or before the include of «pcf8574.h» to overrule the default value used with the begin() call.

  • PCF8574(uint8_t deviceAddress = 0x20, TwoWire *wire = &Wire) Constructor with optional device address, default 0x20, and the optional Wire interface as parameter.
  • bool begin(uint8_t value = PCF8574_INITIAL_VALUE) set the initial value for the pins and masks.
  • bool begin(int sda, int scl, uint8_t value = PCF8574_INITIAL_VALUE) idem, for the ESP32 where one can choose the I2C pins.
  • bool isConnected() checks if the address set in the constructor or by setAddress() is visible on the I2C bus.
  • bool setAddress(const uint8_t deviceAddress) sets the device address after construction. Can be used to switch between PCF8574 modules runtime. Note this corrupts internal buffered values, so one might need to call read8() and/or write8(). Returns true if address can be found on I2C bus.
  • uint8_t getAddress() returns the device address.
  • uint8_t read8() reads all 8 pins at once. This one does the actual reading.
  • uint8_t read(uint8_t pin) reads a single pin; pin = 0..7
  • uint8_t value() returns the last read inputs again, as this information is buffered in the class this is faster than reread the pins.
  • void write8(const uint8_t value) writes all 8 pins at once. This one does the actual writing.
  • uint8_t write(const uint8_t pin, const uint8_t value) writes a single pin; pin = 0..7; value is HIGH(1) or LOW (0)
  • uint8_t valueOut() returns the last written data.

The «button» functions are to be used when you mix input and output on one IC. It does not change / affect the pins used for output by masking these. Typical usage is to call setButtonMask() once in setup as pins do not (often) change during program execution.

  • void setButtonMask(const uint8_t mask) sets the (bit) mask which lines are input.
  • uint8_t getButtonMask() returns the set buttonMask.
  • uint8_t readButton8() use the mask set by setButtonMask to select specific input pins.
  • uint8_t readButton8(const uint8_t mask) use a specific mask to select specific input pins. Note this can be a subset of the pins set with setButtonMask() if one wants to process not all.
  • uint8_t readButton(const uint8_t pin) read a singe input pin.
  • void toggle(const uint8_t pin) toggles a single pin
  • void toggleMask(const uint8_t mask = 0xFF) toggles a selection of pins, if you want to invert all pins use 0xFF (default value).
  • void shiftRight(const uint8_t n = 1) shifts output channels n pins (default 1) pins right (e.g. LEDs ). Fills the higher lines with zero’s.
  • void shiftLeft(const uint8_t n = 1) shifts output channels n pins (default 1) pins left (e.g. LEDs ). Fills the lower lines with zero’s.
  • void rotateRight(const uint8_t n = 1) rotates output channels to right, moving lowest line to highest line.
  • void rotateLeft(const uint8_t n = 1) rotates output channels to left, moving highest line to lowest line.
  • void reverse() reverse the «bit pattern» of the lines, swapping pin 7 with 0, 6 with 1, 5 with 2 etc.

Some convenience wrappers.

  • void select(const uint8_t pin) sets a single pin to HIGH, all others are set to LOW. If pin > 7 all pins are set to LOW. Can be used to select one of n devices.
  • void selectN(const uint8_t pin) sets pins 0..pin to HIGH, all others are set to LOW. If pin > 7 all pins are set to LOW. This can typical be used to implement a VU meter.
  • void selectNone() sets all pins to LOW.
  • void selectAll() sets all pins to HIGH.
  • int lastError() returns the last error from the lib. (see .h file).
name value description
PCF8574_OK 0x00 no error
PCF8574_PIN_ERROR 0x81 pin number out of range
PCF8574_I2C_ERROR 0x82 I2C communication error

It is advised to use pull-up or pull-down resistors so the lines have a defined state at startup.

Источник

skywodd/pcf8574_arduino_library

Use Git or checkout with SVN using the web URL.

Work fast with our official CLI. Learn more.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

PCF8574 Arduino library

The «PCF8574» chip is an I2C I/O expander that free some of your Arduino pins by controlling them over I2C. The PCF8574 is directly powered by the 5v rail of your arduino and let you control 8 I/O with only two common wires (I2C bus) !

Remarks: the PCF8575 is the same chip as the PCF8574 but with 16 I/O instead of 8. A special variant of this library for PCF8575 is also available.

This library has the same API as the standard Arduino GPIO API (digitalRead, digitalWrite, . ).

This library also support interrupts on any of the PCF8574 pins. To do this the library internaly use the «Pin Change Interrupt (PCINT)» capability of AVR microcontrolers. By this way any pins of your Arduino can be used to wire the «INT» pin of the PCF8574.

Remarks: the interrupt «check and process» routine of the library is public and require the user to provide an «global scope» wrapping fonction to work. This is do in order to allow multiple PCF8574 to use the same interrupt pin («INT» pin) on the Arduino board with call to multiple PCF8574 class instances.

About

PCF8574 / PCF8575 Arduino library (version 2.0)

Источник

adafruit/Adafruit_PCF8574

Use Git or checkout with SVN using the web URL.

Work fast with our official CLI. Learn more.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Adafruit PCF8574

This is the Adafruit PCF8574 I2C GPIO Exapnder library

Tested and works great with the Adafruit PCF8574 Breakout Board

This chip uses I2C to communicate, 2 pins are required to interface

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Documentation and doxygen

Documentation is produced by doxygen. Contributions should include documentation for any new code added.

Some examples of how to use doxygen can be found in these guide pages:

Written by ladyada for Adafruit Industries. BSD license, check license.txt for more information All text above must be included in any redistribution

To install, use the Arduino Library Manager and search for «Adafruit PCF8574» and install the library.

About

Arduino library for Adafruit PCF8574 & PCF8575 GPIO expander

Источник

xreef/PCF8574_library

Use Git or checkout with SVN using the web URL.

Work fast with our official CLI. Learn more.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Additional information and documentation on my site: pcf8574 Article.

If you need more pins here you can find the pcf8575 16bit version of the IC.

Library to use I2C analog IC with arduino and esp8266. Can read and write digital value with only 2 wires (perfect for ESP-01).

To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder PCF8574. Check that the PCF8574 folder contains PCF8574\\.cpp and PCF8574.h . Place the DHT library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.

10/08/2022: v2.3.4 Add support for custom SERCOM interface of Arduino SAMD devices. Force SDA SCL to use GPIO numeration for STM32 bug (https://www.mischianti.org/forums/topic/compatible-with-stm32duino/). 28/07/2022: v2.3.3 Force SDA SCL to use GPIO numeration (https://www.mischianti.org/forums/topic/cannot-set-sda-clk-on-esp8266/). 28/07/2022: v2.3.2 Fix the SDA SCL type #58 and add basic support for SAMD device. 26/04/2022: v2.3.1 Fix example for esp32 and double begin issue #56. 06/04/2022: v2.3.0 Fix package size 30/12/2021: v2.2.4 Minor fix and remove deprecated declaration 23/11/2020: v2.2.2 Add multiple implementation for encoder management (you can enable by uncomment relative define)

Reef complete PCF8574 PCF8574AP digital input and output expander with i2c bus.

I try to simplify the use of this IC, with a minimal set of operations.

PCF8574P address map 0x20-0x27 PCF8574AP address map 0x38-0x3f

Constructor: Pass the address of I2C (to check the address use this guide I2cScanner)

For ESP8266 if you want to specify SDA and SCL pins use this:

You must set input/output mode:

then IC as you can see in the image has 8 digital input/output ports:

To read all analog input in one trasmission you can do (even if I use a 10millis debounce time to prevent too much read from i2c):

To follow a request (you can see It on issue #5) I create a define variable to work with low memory devices, if you uncomment this line in the .h file of the library:

Enable low memory props and gain about 7 bytes of memory, and you must use the method to read all like so:

where di is a byte like 1110001, so you must do a bitwise operation to get the data, operation that I already do in the «normal» mode. For example:

if you want to read a single input:

If you want to write a digital value:

You can also use an interrupt pin: You must initialize the pin and the function to call when interrupt raised from PCF8574

Remember you can’t use Serial or Wire on an interrupt function.

It’s better to only set a variable to read on loop:

For the examples I use this wire schema on breadboard:

About

i2c digital expander for Arduino, esp32, SMT32 and ESP8266. Can read write digital values with only 2 wire. Very simple to use and encoder support.

Источник

Adblock
detector