https://github.com/stonatm/sparkfun_com-21209
SparkFun COM-21209 OWire LED python library
https://github.com/stonatm/sparkfun_com-21209
com-21209 led micropython onewire programmable python
Last synced: 4 months ago
JSON representation
SparkFun COM-21209 OWire LED python library
- Host: GitHub
- URL: https://github.com/stonatm/sparkfun_com-21209
- Owner: stonatm
- Created: 2025-05-03T22:47:49.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-05-03T22:48:51.000Z (9 months ago)
- Last Synced: 2025-06-29T22:02:07.244Z (8 months ago)
- Topics: com-21209, led, micropython, onewire, programmable, python
- Language: Python
- Homepage:
- Size: 273 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SparkFun OWire LED python library
Micropython driver for owire led SparkFun COM-21209
## owire_led library
source file: [owire_led.py](./owire_led.py)

---
Initialize led.
```
import owire_led
disp = OWIRE(led_pin)
```
parameters:
**led_pin** - pin number where led is connected.
---
Set color.
```
function set_color(color)
```
parameters:
**color** - chose color from avialable colors:
```
OWIRE.RED
OWIRE.GREEN
OWIRE.BLUE
OWIRE.YELLOW
OWIRE.PURPLE
OWIRE.CYAN_BLUE
OWIRE.WHITE
OWIRE.FULL_COLOR
OWIRE.R_G_W
OWIRE.R_B_W
OWIRE.SIX_COLOR
```
---
Set flashing mode.
```
function set_mode(mode)
```
parameters:
**mode** - mode number, range **0..7**
mode list:
**0** - static, always on
**1** - 8s getting lighter and darker
**2** - slow X background color flashes white (4s flashes 0.5s)
**3** - 2s wave
**4** - slow speed without background color flash X color (idle 4s, flash 0.5s)
**5** - fast X background color flashes white (1s flash 0.125s)
**6** - slow X background color flashes for 0.5s)
**7** - fast flash x color without background color (1s flash 0.125s)
---
Set previously chosen color and mode, send data to led.
```
function send_data()
```
---
### Example:
```
import owire_led
import time
led = OWIRE(LED_PIN)
for led_mode in range(8):
# set led mode
led.set_mode(led_mode)
# set led color and send data to led
led.set_color(led.GREEN)
led.send_data()
time.sleep(8)
led.set_color(led.RED)
led.send_data()
time.sleep(8)
led.set_color(led.YELLOW)
led.send_data()
time.sleep(8)
```