Mcp23017_lib

Easy to use library for the MCP23017 connected to a Raspberry Pi
Alternatives To Mcp23017_lib
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Bian52
8 months ago1other
The Banking Industry Architecture Network e.V. (BIAN) model in Archimate 3
Finflow6
4 years agomitJavaScript
Prototype dashboard for visualising personal spending data created in response to PSD2 regulations 📈
Mcp23017_lib2
6 years agogpl-3.0Python
Easy to use library for the MCP23017 connected to a Raspberry Pi
Groupproject2
3 years agoJavaScript
Team-2/Group-B Project: Quiz Application/Question Bank
Atmsource2
3 years agoJava
Java_Group_project
Databases Fall 2018 19 Lums1
4 years agoHTML
Our course project was a Blood Bank Management system. Back-end in SQL with front-end in Python Flask API.
Edfc Bank Ltd. Financial System1
a year ago
This repository includes different diagrams which have been used for creating the software named as "EDFC Bank Ltd. - Financial System".
Designlabproject1
3 years agomitPython
Maven Credit Card Approval Decision System
Bank Backend1
3 years agoJava
Simple bank backend
Bank Database Sql 20201
3 years agomitPLpgSQL
Bank Database made in SQL
Alternatives To Mcp23017_lib
Select To Compare


Alternative Project Comparisons
Readme

MCP23017 Library

Easy to use library for the MCP23017 connected to a Raspberry Pi.

Installation

i2c is required to be enabled in order to communicate with the chip. Also install these packages:

$ sudo apt-get install python-smbus i2c-tools

Usage

This library aims at being very similar to the RPi.GPIO library. At the moment it provides the following functions:

  • start(address): Starts the library on the specified chip address.

  • setup(pin, mode, pullupEnable): Writes direction (IN, OUT) to the specified pin. pullupEnable enables the internal 100k pullup resistor. Optional, and only works when setting a pin as an input. Valid values are PUHIGH and PULOW.

  • output(pin, dir): Writes state (HIGH, LOW) to the specified pin.

  • input(pin): Reads and returns pin state (True, False)

  • puRead(bank): Reads and returns the pullup registers from both GPIO banks.

    • Valid parameter values: PU_A, PU_B, ALL or leave blank for a default graphic diagram of both banks.
  • dirRead(bank): Reads and returns the direction registers from both GPIO banks.

    • Valid parameter values: BANK_A, BANK_B, ALL or leave blank for a default graphic diagram of both banks.
  • latRead(bank): Reads and returns the latch registers from both GPIO banks.

    • Valid parameter values: LAT_A, LAT_B, ALL or leave blank for a default graphic diagram of both banks.

Please refer to the image below for the pin mapping.

Constant list

  • MCP.OUT = 1
  • MCP.IN = 0
  • MCP.BANK_A = 0
  • MCP.BANK_B = 1
  • MCP.ALL = 2
  • MCP.LAT_A = 3
  • MCP.LAT_B = 4
  • MCP.PU_A = 5
  • MCP.PU_B = 6
  • MCP.HIGH = 1
  • MCP.LOW = 0
  • MCP.PUHIGH = 1
  • MCP.PULOW = 0

Pinout

Pins are mapped according to this diagram:

Diagram

Code example

This example will set pin #2 as an input, with the pullup resistor enabled and #1 as an output. When the input goes high, pin #1 will also go high.

import mcp23017_lib as MCP

MCP.start(0x26)

MCP.setup(2, MCP.IN, MCP.PUHIGH)
MCP.setup(1, MCP.OUT)

while 1:
   if(MCP.input(2)):
      MCP.output(1, MCP.HIGH)
   else:
      MCP.output(1, MCP.LOW)

TODO list

  • [x] Do not use hardcoded i2c address
  • [x] Add pullup function
  • [ ] Add raw write function
  • [x] Finish function documentation
  • [ ] GPIO Zero Support

Contributors

Development:

Debugging:

Contributing

  • The code is licensed under the GPL V3
  • Feel free to contribute to the code
Popular Diagram Projects
Popular Bank Projects
Popular User Interface Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Python
Diagram
Bank
Gpio