Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
9d0d6d38
Commit
9d0d6d38
authored
Nov 29, 2015
by
Paul Sokolovsky
Browse files
examples/accel_i2c.py: Switch to "machine" module.
parent
698a6a9d
Changes
1
Hide whitespace changes
Inline
Side-by-side
examples/accel_i2c.py
View file @
9d0d6d38
...
...
@@ -4,16 +4,17 @@
# example. For the latter, using pyb.Accel class is
# much easier.
import
pyb
from
machine
import
Pin
from
machine
import
I2C
import
time
# Accelerometer needs to be powered on first. Even
# though signal is called "AVDD", and there's separate
# "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
)
i2c
=
pyb
.
I2C
(
1
)
i2c
=
I2C
(
1
,
baudrate
=
100000
)
addrs
=
i2c
.
scan
()
print
(
"Scanning devices:"
,
[
hex
(
x
)
for
x
in
addrs
])
if
0x4c
not
in
addrs
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment