Skip to content
Snippets Groups Projects
Commit 9d0d6d38 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

examples/accel_i2c.py: Switch to "machine" module.

parent 698a6a9d
Branches
No related tags found
No related merge requests found
...@@ -4,16 +4,17 @@ ...@@ -4,16 +4,17 @@
# example. For the latter, using pyb.Accel class is # example. For the latter, using pyb.Accel class is
# much easier. # much easier.
import pyb from machine import Pin
from machine import I2C
import time import time
# Accelerometer needs to be powered on first. Even # Accelerometer needs to be powered on first. Even
# though signal is called "AVDD", and there's separate # though signal is called "AVDD", and there's separate
# "DVDD", without AVDD, it won't event talk on I2C bus. # "DVDD", without AVDD, it won't event talk on I2C bus.
accel_pwr = pyb.Pin("MMA_AVDD") accel_pwr = Pin("MMA_AVDD")
accel_pwr.value(1) accel_pwr.value(1)
i2c = pyb.I2C(1) i2c = I2C(1, baudrate=100000)
addrs = i2c.scan() addrs = i2c.scan()
print("Scanning devices:", [hex(x) for x in addrs]) print("Scanning devices:", [hex(x) for x in addrs])
if 0x4c not in addrs: if 0x4c not in addrs:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment