LoginSignup
0
0

More than 5 years have passed since last update.

raspberry pi で、MCP23017 の出力ポートを使う smbus版

Last updated at Posted at 2017-05-29
mcp23017_smbus_out.py
#! /usr/bin/python3
# -*- coding: utf-8 -*-
#
#   mcp23017_smbus_out.py
#
#                   May/29/2017
#
# ----------------------------------------------------------------
import sys
import smbus
import  time
#
# ----------------------------------------------------------------
sys.stderr.write("*** start ***\n")
CHANNEL   = 1
ICADDR    = 0x20
REG_IODIR = 0x00
REG_OLAT = 0x14
#
bus = smbus.SMBus(CHANNEL)
bus.write_byte_data(ICADDR, REG_IODIR, 0x00)
time.sleep (1)
#
for value in [0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x00]:
    print(value)
    bus.write_byte_data(ICADDR, REG_OLAT,value)
    time.sleep (0.5)
#
sys.stderr.write("*** end ***\n")
# ----------------------------------------------------------------
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0