Skip to content

Commit 1ecee56

Browse files
committed
Adding my August 2014 talk on MicroPython.
1 parent 2babf8c commit 1ecee56

File tree

7 files changed

+96
-0
lines changed

7 files changed

+96
-0
lines changed

2014-08/micropython/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Introduction to MicroPython
2+
============================
3+
JR Rickerson
4+
5+
Overview
6+
--------
7+
MicroPython is a reimplementation of the Python 3 language for micrcontrollers.
8+
The Kickstarter project provided a copy of the MicroPython code embedded on a
9+
a small microcontroller board called the "pyboard," and a Python module to
10+
provide access to the components on the board.
11+
12+
Slides
13+
------
14+
Slides are available via Google Docs:
15+
https://docs.google.com/presentation/d/1Y3Wslr_so9h0rhLIcHzoOU1z7XNXuJMO1-rfwCNNMuM/edit?usp=sharing
16+
17+
Code
18+
----
19+
Demo scripts presented during the talk can be found on Github:
20+
https://github.com/pyatl/talks/tree/master/2014-08/micropython/demo
21+
22+
Resources
23+
---------
24+
Resources for learning more:
25+
- MicroPython website (info, docs, diagrams, etc): http://www.micropython.org
26+
- AdaFruit (electronics kits, books, parts): http://www.adafruit.com
27+
- SparkFun (electronics kits, books, parts, projects): http://www.sparkfun.com
28+
- Microcenter (local electronics store with hobby section): http://www.microcenter.com
29+

2014-08/micropython/demo/__init__.py

Whitespace-only changes.
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
""" Interact with the accelerometer. Light up different leds
2+
when different axes are not level, within a tolerance. """
3+
import pyb
4+
5+
ledx = pyb.LED(1)
6+
ledy = pyb.LED(2)
7+
ledz = pyb.LED(3)
8+
accel = pyb.Accel()
9+
SENSITIVITY = 5
10+
11+
def run():
12+
while True:
13+
x = accel.x()
14+
y = accel.y()
15+
z = accel.z()
16+
if abs(x) > SENSITIVITY:
17+
ledx.on()
18+
else:
19+
ledx.off()
20+
if abs(y) > SENSITIVITY:
21+
ledy.on()
22+
else:
23+
ledy.off()
24+
if abs(z) > SENSITIVITY:
25+
ledz.on()
26+
else:
27+
ledz.off()
28+
pyb.delay(200)
29+

2014-08/micropython/demo/hello.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
""" Hello World on the pyboard. Just turn on the blue LED """
2+
import pyb
3+
4+
led_blue = pyb.LED(4)
5+
led_blue.on()

2014-08/micropython/demo/leds.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
""" Make your pyboard into a disco! Alternate leds in a cycle """
2+
import pyb
3+
4+
led_list = [pyb.LED(i) for i in range(1, 5)]
5+
6+
def run():
7+
i = 0
8+
while True:
9+
led_list[i].off()
10+
i += 1
11+
if i >= len(led_list):
12+
i = 0
13+
led_list[i].on()
14+
pyb.delay(200)
15+

2014-08/micropython/demo/loop.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
""" Looping your program - Make the red LED blink on and off every 500 ms """
2+
import pyb
3+
4+
led_red = pyb.LED(1)
5+
6+
def run():
7+
while True:
8+
led_red.toggle()
9+
pyb.delay(500)
10+

2014-08/micropython/demo/switch.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
""" Use the USR switch on the pyboard to toggle the blue led on and off """
2+
import pyb
3+
4+
led = pyb.LED(4)
5+
6+
def run():
7+
switch = pyb.Switch()
8+
switch.callback(lambda: led.toggle())

0 commit comments

Comments
 (0)