Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
15a5738e
Commit
15a5738e
authored
11 years ago
by
Damien George
Browse files
Options
Downloads
Plain Diff
Merge branch 'LED-Fix' of github.com:Metallicow/micropython into Metallicow-LED-Fix
parents
fcc9cf63
9500e984
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/ledangle.py
+3
-3
3 additions, 3 deletions
examples/ledangle.py
examples/switch.py
+46
-0
46 additions, 0 deletions
examples/switch.py
with
49 additions
and
3 deletions
examples/ledangle.py
+
3
−
3
View file @
15a5738e
...
@@ -2,8 +2,8 @@ import pyb
...
@@ -2,8 +2,8 @@ import pyb
def
led_angle
(
seconds_to_run_for
):
def
led_angle
(
seconds_to_run_for
):
# make LED objects
# make LED objects
l1
=
pyb
.
L
ed
(
1
)
l1
=
pyb
.
L
ED
(
1
)
l2
=
pyb
.
L
ed
(
2
)
l2
=
pyb
.
L
ED
(
2
)
accel
=
pyb
.
Accel
()
accel
=
pyb
.
Accel
()
for
i
in
range
(
20
*
seconds_to_run_for
):
for
i
in
range
(
20
*
seconds_to_run_for
):
...
...
This diff is collapsed.
Click to expand it.
examples/switch.py
0 → 100644
+
46
−
0
View file @
15a5738e
__doc__
=
"""
switch.py
=========
Light up some leds when the USR switch on the pyboard is pressed.
Example Usage::
Micro Python v1.0.1 on 2014-05-12; PYBv1.0 with STM32F405RG
Type
"
help()
"
for more information.
>>>
import
switch
>>>
switch
.
run_loop
([
2
,
3
])
Loop
started
.
Press
Ctrl
+
C
to
break
out
of
the
loop
.
"""
import
pyb
switch
=
pyb
.
Switch
()
red_led
=
pyb
.
LED
(
1
)
green_led
=
pyb
.
LED
(
2
)
orange_led
=
pyb
.
LED
(
3
)
blue_led
=
pyb
.
LED
(
4
)
all_leds
=
[
red_led
,
green_led
,
orange_led
,
blue_led
]
def
run_loop
(
use_leds
=
[]):
"""
Start the loop.
:param `use_leds`: Which leds to light up upon switch press.
:type `use_leds`: list of integers [1-4]
"""
print
(
'
Loop started.
\n
Press Ctrl+C to break out of the loop.
'
)
leds
=
[
all_leds
[
i
-
1
]
for
i
in
use_leds
]
while
1
:
try
:
if
switch
():
[
led
.
on
()
for
led
in
leds
]
else
:
[
led
.
off
()
for
led
in
leds
]
except
OSError
:
# VCPInterrupt # Ctrl+C in interpreter mode.
break
if
__name__
==
'
__main__
'
:
run_loop
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment