Giter Club home page Giter Club logo

micropython-pca9551's Introduction

PCA9551 Python Library

Welcome to the PCA9551 Python library repository! This library is designed to facilitate communication with the PCA9551 I2C LED controller from your MicroPython projects. This README will guide you through the key features and usage of this library, making it accessible to developers of all skill levels.

Table of Contents

Introduction

The PCA9551 is an I2C LED controller that allows you to control LED outputs and implement various lighting effects. This library simplifies the interaction with the PCA9551 by providing a Python interface to control the LEDs and their brightness.

Installation

You can install this library in your MicroPython environment by following these steps:

  1. Download the pca9551.py file from this repository.
  2. Place the pca9551.py file in your MicroPython project directory.

Usage

Initializing PCA9551

To get started with the PCA9551 library, you need to initialize an instance of the PCA9551 class. The class constructor takes two callback functions for I2C operations:

from pca9551 import PCA9551

def write_callback(i2c_address, register_address, data):
    # Implement I2C write operation here
    pass

def read_callback(i2c_address, register_address, num_read):
    # Implement I2C read operation here
    pass

# Initialize PCA9551 instance
pca = PCA9551(write_callback, read_callback)

Reading Inputs

You can read the input state of the PCA9551 using the read_inputs method:

input_state = pca.read_inputs()

Controlling LEDs

The PCA9551 library provides methods for controlling LED states. You can turn LEDs on, off, or set them to PWM modes. For example:

# Turn on specific LEDs
pca.leds_on([0, 1, 2])

# Turn off specific LEDs
pca.leds_off([1, 3])

# Set specific LEDs to PWM0 mode
pca.leds_pwm0([2, 4])

PWM Control

You can also control the duty cycle of PWM0 and PWM1 outputs:

# Get the current duty cycle of PWM0
duty_cycle = pca.pwm0_duty_cycle

# Set the duty cycle of PWM0 (0.0 to 1.0)
pca.pwm0_duty_cycle = 0.5

# Get the current duty cycle of PWM1
duty_cycle = pca.pwm1_duty_cycle

# Set the duty cycle of PWM1 (0.0 to 1.0)
pca.pwm1_duty_cycle = 0.3

Contributing

We welcome contributions to this library. If you have suggestions, bug reports, or want to add new features, please create an issue or submit a pull request.

micropython-pca9551's People

Contributors

wese3112 avatar

Watchers

 avatar  avatar

micropython-pca9551's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.