pimoroni-pico/micropython/examples/plasma_stick/README.md

153 wiersze
5.3 KiB
Markdown
Czysty Zwykły widok Historia

2022-10-12 17:23:24 +00:00
# Plasma Stick MicroPython Examples <!-- omit in toc -->
- [About Plasma Stick](#about-plasma-stick)
2022-10-12 17:38:14 +00:00
- [Plasma Library](#plasma-library)
2022-10-12 17:23:24 +00:00
- [Using Breakouts](#using-breakouts)
- [Basic Examples](#basic-examples)
- [Alternating Blinkies](#alternating-blinkies)
- [Fire](#fire)
- [Moon](#moon)
- [Rainbows](#rainbows)
- [Thermometer](#thermometer)
- [Advanced Examples](#advanced-examples)
- [CO2](#co2)
- [Encoder](#encoder)
- [Moon (RTC)](#moon-rtc)
- [PIR](#pir)
- [Thermometer (BME280)](#thermometer-bme280)
- [Wireless Examples](#wireless-examples)
- [Cheerlights](#cheerlights)
- [Weather](#weather)
## About Plasma Stick
2022-10-18 13:25:02 +00:00
Plasma Stick 2040 W is a compact controller for WS2812 strip, powered by Raspberry Pi Pico W and perfect for easy, seasonal lighting. It has built in ✨wireless connectivity✨, courtesy of the onboard Pico W.
2022-10-12 17:23:24 +00:00
2022-10-18 13:25:02 +00:00
You can buy one on its own or in a kit:
2022-10-12 17:38:14 +00:00
2022-10-18 13:25:02 +00:00
- [Plasma Stick 2040 W](https://shop.pimoroni.com/products/plasma-stick-2040-w)
2022-10-12 17:23:24 +00:00
2022-10-18 13:25:02 +00:00
- [Wireless Plasma Kit](https://shop.pimoroni.com/products/wireless-plasma-kit)
Plasma Stick ships with MicroPython firmware pre-loaded, but you can download the most recent version at the link below (you'll want the `pimoroni-picow` image).
2022-10-12 17:23:24 +00:00
- [MicroPython releases](https://github.com/pimoroni/pimoroni-pico/releases)
2022-10-12 17:38:14 +00:00
## Plasma Library
2022-10-12 17:23:24 +00:00
2022-10-18 13:25:02 +00:00
You can control your WS2812 / NeoPixel™ strip using our handy MicroPython Plasma library.
2022-10-12 17:23:24 +00:00
- [PicoGraphics MicroPython function reference](../../modules/plasma)
## Using Breakouts
2022-10-18 13:25:02 +00:00
Plasma Stick has a Qw/ST (Qwiic/STEMMA QT) connector. Breakouts with Qw/ST connectors, can be plugged straight in with a [JST-SH to JST-SH cable](https://shop.pimoroni.com/products/jst-sh-cable-qwiic-stemma-qt-compatible?variant=31910609813587). You can connect I2C Breakout Garden breakouts without Qw/ST connectors using a [JST-SH to JST-SH cable](https://shop.pimoroni.com/products/jst-sh-cable-qwiic-stemma-qt-compatible?variant=31910609813587) and a [Qw/ST to Breakout Garden adaptor](https://shop.pimoroni.com/products/stemma-qt-qwiic-to-breakout-garden-adapter).
2022-10-12 17:23:24 +00:00
2022-10-12 17:32:00 +00:00
- [List of breakouts currently supported in our C++/MicroPython build](https://github.com/pimoroni/pimoroni-pico#breakouts)
2022-10-12 17:23:24 +00:00
Plasma Stick uses GP4 and GP5 for its I2C interface. You can use the constants in the shared `pimoroni` module to set up the I2C interface:
```python
from pimoroni_i2c import PimoroniI2C
from pimoroni import PINS_BREAKOUT_GARDEN
i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
```
Alternatively, you can specify the pin numbers directly:
```python
from pimoroni_i2c import PimoroniI2C
i2c = PimoroniI2C(sda=(4), scl=(5))
```
## Basic Examples
### Alternating Blinkies
2022-10-18 13:25:02 +00:00
2022-10-12 17:23:24 +00:00
[alternating-blinkies.py](alternating-blinkies.py)
A simple example with two alternating colours, great for festive lights!
### Fire
2022-10-18 13:25:02 +00:00
2022-10-12 17:23:24 +00:00
[fire.py](fire.py)
2022-10-12 17:32:00 +00:00
A simple 🔥 fire effect example 🤘 (warning, flashy).
2022-10-12 17:23:24 +00:00
### Moon
2022-10-18 13:25:02 +00:00
2022-10-12 17:23:24 +00:00
[moon.py](moon.py)
Spooky moon simulator - the LEDs will get brighter as midnight approaches!
Needs to be run from Thonny to get the correct time.
### Rainbows
2022-10-18 13:25:02 +00:00
2022-10-12 17:23:24 +00:00
[rainbows.py](rainbows.py)
Some good old fashioned rainbows!
### Thermometer
2022-10-18 13:25:02 +00:00
2022-10-12 17:23:24 +00:00
[thermometer_pico.py](thermometer_pico.py)
Reads the temperature from the Pico W's internal temperature sensor and changes the LED strip an appropriate colour.
## Advanced Examples
These examples require additional hardware.
### CO2
2022-10-18 13:25:02 +00:00
2022-10-12 17:23:24 +00:00
[co2.py](co2.py)
2022-10-12 17:32:00 +00:00
Reads CO2 level from a [SCD41 CO2 breakout](https://shop.pimoroni.com/products/scd41-co2-sensor-breakout) and turns the LED strip an appropriate colour.
2022-10-12 17:23:24 +00:00
### Encoder
2022-10-18 13:25:02 +00:00
2022-10-12 17:23:24 +00:00
[encoder.py](encoder.py)
2022-10-12 17:32:00 +00:00
Adjust the colour of your LEDs easily with an [RGB Encoder breakout](https://shop.pimoroni.com/products/rgb-encoder-breakout?variant=32236590399571).
2022-10-12 17:23:24 +00:00
### Moon (RTC)
2022-10-18 13:25:02 +00:00
2022-10-12 17:23:24 +00:00
[moon_rtc.py](moon_rtc.py)
Spooky moon simulator - the LEDs will get brighter as midnight approaches!
2022-10-12 17:32:00 +00:00
Gets the time from a [RV3028 RTC breakout](https://shop.pimoroni.com/products/rv3028-real-time-clock-rtc-breakout).
2022-10-12 17:23:24 +00:00
### PIR
2022-10-18 13:25:02 +00:00
2022-10-12 17:23:24 +00:00
[pir.py](pir.py)
Connect a PIR motion sensor and trigger some ominous effects. We like [these ones](https://shop.pimoroni.com/products/micro-pir-motion-sensor-2-pcs) - we connected ours to the QwST connector using [this cable](https://shop.pimoroni.com/products/jst-sh-cable-qwiic-stemma-qt-compatible?variant=31910609846355) and some [socket to socket](https://shop.pimoroni.com/products/jumper-jerky-junior?variant=1076482185) jumper jerky.
### Thermometer (BME280)
2022-10-18 13:25:02 +00:00
2022-10-12 17:23:24 +00:00
[thermometer_bme280.py](thermometer_bme280.py)
Reads the temperature from a [BME280 breakout](https://shop.pimoroni.com/products/bme280-breakout) and changes the LED strip an appropriate colour.
## Wireless Examples
The wireless examples need `network_manager.py` and `WIFI_CONFIG.py` from the `common` directory to be saved to your Pico W. Open up `WIFI_CONFIG.py` in Thonny to add your wifi details (and save it when you're done).
- [micropython/examples/common](../../examples/common)
### Cheerlights
2022-10-18 13:25:02 +00:00
2022-10-12 17:23:24 +00:00
[cheerlights.py](cheerlights.py)
Sets your LED strip to the current #cheerlights colour.
2022-10-12 17:38:14 +00:00
Find out more about the Cheerlights API at [https://cheerlights.com/].
2022-10-12 17:23:24 +00:00
### Weather
2022-10-18 13:25:02 +00:00
2022-10-12 17:23:24 +00:00
[weather.py](weather.py)
This Plasma Stick example connects to Open Meteo to access the current weather conditions.
It then does some cool weather appropriate stuff with LEDs.
2022-10-12 17:38:14 +00:00
Find out more about the Open Meteo API at [https://open-meteo.com].