---
title: "【Raspberry Pi】Extra 1 - Rainbow LED, RGB LED, Laser Sensor"
url: "https://ouro.foundation/files/ache0108/raspberry-piextra-1-rainbow-led-rgb-led-laser-sensor"
id: "8f8dc9e5-f615-4d7e-96c7-214e0f729857"
type: "file"
---

# 【Raspberry Pi】Extra 1 - Rainbow LED, RGB LED, Laser Sensor

File by @ache0108 in #ache0108 (all) · .md · 1.8 KB

- Asset id: `8f8dc9e5-f615-4d7e-96c7-214e0f729857`
- Page: https://ouro.foundation/files/ache0108/raspberry-piextra-1-rainbow-led-rgb-led-laser-sensor



## Contents

```md

## I. Rainbow LED
- Characteristics: **Built-in IC chip**, automatically changes color and speed, **no coding required**
- Wiring: Module integrates driving circuit, simple wiring

---

## II. RGB LED (Programmable Full Color)
### 1. Features
- Pins: One more than bi-color LED, total **Red, Green, Blue 3 pins**
- Control: Three-channel PWM color mixing,可以实现 **any color**
- Application: Projects requiring precise color control

### 2. Code Implementation Key Points
- Dependency Libraries: `gpiozero`, `colorzero`
- Typical Pins: **Red 16, Green 26, Blue 19**
- Control Logic:
  1. Initialize `RGBLED(red_pin, green_pin, blue_pin)`
  2. `set_color()`: Set color using string
  3. `start_color_cycle()`: Automatic color cycling
  4. Must call `close()` on exit to release GPIO

---

## III. Laser Sensor Control
### 1. Characteristics
- Advantages: **High precision, high speed, strong anti-interference**
- Applications: Robot vacuum mapping, industrial ranging, detection

### 2. Code Implementation
- Pin: Default **GPIO16**
- Logic Level: `active_high=True` (3.3V high level activates)
- Core Methods:
  - `on()` / `off()`: Switch on/off
  - `toggle()`: Flip state
  - `blink()`: Blink at intervals
- Safety: Use `try-except-finally` to catch exit and ensure resource release

---

## IV. Knowledge Summary
| Model | Functional Highlights | Technical Parameters | Application Scenarios | Competitor Comparison |
|---|---|---|---|---|
| Rainbow LED Module | Built-in IC, auto-color, no programming | Integrated driver chip | Decoration, DIY | No control circuit needed |
| RGB LED | Three-channel mixing, programmable any color | 3 GPIO pins | Precise color control | Richer color than bi-color LED |
| Laser Sensor | High precision ranging, strong anti-interference | 3.3V high activation | Ranging, detection, mapping | Higher precision than ultrasonic |
```

## Use it

- Download: https://database.ouro.foundation/storage/v1/object/public/public-files/dd119e84-657f-4895-b379-7e7f600ab9d7/019dceec-f894-743a-a25c-8efd3235b57e.md?v=1777293135960
- Over Ouro MCP: `download_asset(id="8f8dc9e5-f615-4d7e-96c7-214e0f729857")` returns the file or a download link.
- Find routes that take it: `get_compatible_routes(asset_id="8f8dc9e5-f615-4d7e-96c7-214e0f729857")`, then pass it as `input_assets={"file": "8f8dc9e5-f615-4d7e-96c7-214e0f729857"}`.
- From Python: `ouro.files.retrieve("8f8dc9e5-f615-4d7e-96c7-214e0f729857")`
