heres my code:
from machine import I2C
import time
print(" +-------------------------------------+")
print(" | XBee MicroPython I2C Scanner Sample |")
print(" +-------------------------------------+
")
# Instantiate an I2C peripheral.
i2c = I2C(1)
# Scan for I2C slaves connected to the interface and print their address.
for address in i2c.scan():
print("- I2C device found at address: %s" % hex(address))
DEVICE = 0x20 # Device address (A0-A2)
IODIRA = 0x00 # Pin direction register
OLATA = 0x14 # Register for outputs
GPIOA = 0x12 # Register for inputs
# Set all GPA pins as outputs by setting
# all bits of IODIRA register to 0
i2c.writeto_mem(DEVICE, IODIRA, 0x00)
# Set output all 7 output bits to 0
i2c.writeto_mem(DEVICE, OLATA, 0)
for MyData in range(1, 8):
# Count from 1 to 8 which in binary will count
# from 001 to 111
i2c.writeto_mem(DEVICE, OLATA, MyData)
print(MyData)
time.sleep(1)
# Set all bits to zero
i2c.writeto_mem(DEVICE, OLATA, 0)
The 3rd parameter in i2c.writeto_mem() tells me it should be a bytearray instead of a byte. what would a byte array look like? How would I pass in a bytearray that just contained sending a bit of value 1.
thanks