Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
card10
logix
Commits
47314a35
Commit
47314a35
authored
Dec 26, 2019
by
schneider
Browse files
more sewable led content
parent
9c825fc6
Pipeline
#4389
passed with stage
in 15 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
en/tutorials/sewable_leds.md
View file @
47314a35
...
...
@@ -69,5 +69,34 @@ Your LED should light up yellow now :)
### Sample application
This example queries the state of the lower right button and turns multiple RGB LEDs on when the button is pressed:
You can adjust the color, number of leds and which pin is used.
```
import buttons
import ws2812
import utime
COLOR_ON = color.YELLOW * 0.2 # 20% yellow
COLOR_OFF = [0, 0, 0]
LED_NUM = 2 # number of attached LEDs
LED_PIN = gpio.WRISTBAND_1
state = False
while True:
if buttons.read(buttons.BOTTOM_RIGHT):
state = not state
if state:
color = COLOR_ON
else:
color = COLOR_OFF
ws2812.set_all(LED_PIN, [color] * LED_NUM)
# Debounce the button
utime.sleep(0.1)
while buttons.read(buttons.BOTTOM_RIGHT): pass
utime.sleep(0.1)
```
An example which connects the accelerometer with multiple RGB LEDs. They start lighting up when the card10 is moved:
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