Giter Club home page Giter Club logo

micropython-sx1509-library's Introduction

Micropython driver for SX1509 16-channel GPIO with LED Driver and Keypad Engine. This library is work-in-progress.

IMPORTANT!!

This lib is experimental, may not work. Its my first attempt at an I2C library in Micropython.
Comments/updates here --> micropython.org/viewtopic.php?f=2&t=9178.


NOTE!!

  • PWM & Keypad engine not working yet.
  • Only pins 8 to 15 working as digital expander pins much like a PCF8574.

Change log:

  • 0.0.1 20201021 First release. It can reset, can read & write a value to pin 0.
  • 0.0.2 20201029
  • 0.0.3 20230301 Bijgewerkt met ChatGPT https://chat.openai.com
    • Functional working: digitalWrite(pinNr, True|False) works.

Lijst van TODO

  • TODO: test PWM / LED breaething.
  • TODO: Implementeer het Keypad engine.

HOWTO: Overzetten naar Micropython

Stap 1. Download Thonny IDE.
Stap 2. Verbind aan jouw Micropython apparaat via USB.
Stap 3. Upload die lib middels Thonny' Save As.. feature.
Stap 4. Verbind jouw sx1509 aan de ESP32
Stap 5. Run de democode hieronder in Thonny.

Rrequirements

  • ESP32 want die lib past niet in een ESP8266.

Voorbeeld gebruik

WORK-in-Progress!!

import utime
import random
from machine import Pin, PWM, ADC
import esp
import gc
esp.osdebug(None)

gc.collect()

class mainAPP:
    def __init__(self):
        self._adc_pin = 13
        self._adc = (Pin(self._adc_pin))
        random.seed(1024)        

    def main(self):
        aantalLoops =  1000/60 * 60 * 60 * 24
        
        
        led = PWM(Pin(self._adc_pin))
        led.freq(500)
        
        for i1 in range(0, aantalLoops):
            duty1 = int(random.random()*1000)
            for dutCnt1 in range(1, int(random.random()*100)):
                led.duty(duty1)
                utime.sleep_ms(int(random.random()*100))
            
            led.duty(0)
            sleepTime1 = int(random.random()*1000)
            print(f'sleepTime1: {sleepTime1}ms')
            utime.sleep_ms(sleepTime1)
            if(i1 % 10 == 0):
                print("Led knipperen op PIN=",self._adc_pin ,  i1,"van",aantalLoops)
   
   
if __name__ == '__main__':
    print("App start")
    main1 = mainAPP()
    main1.main()
    print("App eind")

Info

CREDITS

#easylab4kids

micropython-sx1509-library's People

Contributors

pappavis avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.