Outils pour utilisateurs

Outils du site


start:raspberry:i2c

Ceci est une ancienne révision du document !


I2C raspberry

Installer le module smsbus python3
 sudo apt-get install  python3-smbus

faire :

 
 sudo pip list ( pour verifier l'installation )

Programme en python

exemple010.py
from smbus import SMBus
 
addr = 0x55 # bus address
bus = SMBus(1) # indicates /dev/ic2-1
 
numb = 1
 
print ("Enter 1 for ON or 0 for OFF")
 
while numb == 1:
    ledstate = input(">>>>")
    if ledstate == "1":
        bus.write_byte(addr, 0x1) # switch it on 
    elif ledstate == "0":
        bus.write_byte(addr, 0x0) # switch it off
    else:
        numb = 0
/home/chanteri/www/fablab37110/data/attic/start/raspberry/i2c.1740936129.txt.gz · Dernière modification : 2025/03/02 18:22 de admin