Outils pour utilisateurs

Outils du site


start:raspberry:i2c

Ceci est une ancienne révision du document !


Table des matières

I2C raspberry

exemple010.py
# Raspberry Pi Master for Arduino Slave
# i2c_master_pi.py
# Connects to Arduino via I2C
# DroneBot Workshop 2019
# https://dronebotworkshop.com
from smbus import SMBus
 
addr = 0x8 # 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.1740934465.txt.gz · Dernière modification : 2025/03/02 17:54 de admin