micropython-skills/actuator
MicroPython actuator control — GPIO output, PWM (LED/servo/motor), stepper motor, WS2812 NeoPixel, buzzer.
About this skill
The MicroPython Actuator Control skill equips AI coding agents with ready-to-use Python code snippets for direct interaction with physical hardware through MicroPython devices. It covers fundamental output operations such as setting digital GPIO pins high or low (e.g., for LEDs or relays), controlling PWM signals for tasks like LED dimming or servo motor positioning, and executing simple LED blink patterns. The skill is designed with a "Cautious tier" approach, requiring explicit user confirmation on hardware connections, load types, and wiring before execution, ensuring safety and preventing potential damage to components. This skill is invaluable for developers, hobbyists, and educators working with embedded systems who need to quickly prototype or debug hardware interactions using MicroPython. By providing pre-tested code templates, it significantly reduces the time and effort typically spent on writing low-level hardware control logic. Users can leverage an AI agent to generate, adapt, and execute these commands, streamlining the development process for IoT devices, robotics, or any project involving MicroPython-enabled microcontrollers. The primary benefit is accelerated development and increased reliability when interacting with hardware. The AI agent can adapt these templates to specific pin numbers and parameters provided by the user, offering a guided and safer way to experiment with physical outputs. This makes complex tasks like precise servo control or NeoPixel animations more accessible, even for those less familiar with the intricacies of MicroPython hardware APIs.
Best use case
The primary use case for this skill is rapid prototyping and debugging of hardware interfaces on MicroPython-enabled microcontrollers. It benefits embedded systems developers, hobbyists, and educators who need to control physical actuators like LEDs, motors, servos, or buzzers. Users can quickly test output functionalities, verify wiring, and experiment with different control parameters without writing extensive boilerplate code, making it ideal for IoT projects, robotics, or custom electronics.
MicroPython actuator control — GPIO output, PWM (LED/servo/motor), stepper motor, WS2812 NeoPixel, buzzer.
The user should expect their MicroPython device to physically activate an attached actuator (e.g., an LED to turn on, a motor to spin, a servo to move) according to the specified parameters, along with a JSON `RESULT` message from the agent.
Practical example
Example input
Can you help me turn on an LED connected to GPIO pin 2 on my ESP32 using MicroPython? I've confirmed the wiring.
Example output
Okay, I will execute the MicroPython code to set GPIO pin 2 HIGH. Confirm this is correct.
`RESULT:{"pin": 2, "state": "HIGH"}`When to use this skill
- When needing to control basic digital outputs (LEDs, relays) on a MicroPython device.
- For dimming LEDs or positioning servo motors using PWM with MicroPython.
- To quickly prototype and test actuator responses on embedded hardware.
- When an AI agent needs to guide a user through safe hardware interaction steps.
When not to use this skill
- For complex, high-speed, or real-time control systems requiring precise timing not achievable via scripting.
- When controlling actuators that require very high current or voltage without proper external driver circuitry.
- If the user does not have a MicroPython device or the necessary physical wiring prepared.
- For purely software-based tasks that do not involve physical hardware interaction.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/actuator/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How micropython-skills/actuator Compares
| Feature / Agent | micropython-skills/actuator | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | easy | N/A |
Frequently Asked Questions
What does this skill do?
MicroPython actuator control — GPIO output, PWM (LED/servo/motor), stepper motor, WS2812 NeoPixel, buzzer.
How difficult is it to install?
The installation complexity is rated as easy. You can find the installation instructions above.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
SKILL.md Source
# Actuator Control
Code templates for controlling outputs and actuators on MicroPython devices.
All actuator operations are **Cautious tier** — inform the user what you're about to do before executing.
Before running any actuator code, confirm with the user:
- Which GPIO pin(s) are connected
- What the load is (LED, motor, relay, etc.)
- Whether wiring has been verified (especially for high-current devices)
## GPIO Output (Digital High/Low)
```python
from machine import Pin
import json
try:
led = Pin(2, Pin.OUT) # Built-in LED on many ESP32 boards
led.value(1) # Turn ON
print("RESULT:" + json.dumps({"pin": 2, "state": "HIGH"}))
except Exception as e:
print("ERROR:" + str(e))
```
For relay control, same pattern but be aware relays may be active-low:
```python
relay = Pin(5, Pin.OUT)
relay.value(0) # Active-low relay: 0 = ON, 1 = OFF
```
## LED Blink
```python
from machine import Pin
import time, json
try:
led = Pin(2, Pin.OUT)
count = 5
for i in range(count):
led.value(1)
time.sleep(0.5)
led.value(0)
time.sleep(0.5)
print("RESULT:" + json.dumps({"blinked": count}))
except Exception as e:
print("ERROR:" + str(e))
```
## PWM — LED Dimming
```python
from machine import Pin, PWM
import json
try:
pwm = PWM(Pin(2), freq=1000)
# duty: 0 (off) to 1023 (full brightness) on ESP32
# On RP2040, duty range is 0-65535
duty_value = 512 # ~50% brightness
pwm.duty(duty_value)
print("RESULT:" + json.dumps({"pin": 2, "freq": 1000, "duty": duty_value}))
except Exception as e:
print("ERROR:" + str(e))
finally:
# Always offer cleanup:
# pwm.deinit()
pass
```
## PWM — Servo Motor
Standard servos: 50Hz PWM, pulse width 0.5ms (0deg) to 2.5ms (180deg).
```python
from machine import Pin, PWM
import json
try:
servo = PWM(Pin(13), freq=50)
def set_angle(angle):
# Map 0-180 degrees to duty cycle
# ESP32: duty 0-1023 at 50Hz (20ms period)
# 0.5ms = 2.5% duty = 26, 2.5ms = 12.5% duty = 128
duty = int(26 + (angle / 180) * (128 - 26))
servo.duty(duty)
return duty
target = 90 # degrees
d = set_angle(target)
print("RESULT:" + json.dumps({"angle": target, "duty": d}))
except Exception as e:
print("ERROR:" + str(e))
```
## PWM — DC Motor Speed
Control motor speed via PWM through a driver (L298N, L293D, TB6612, etc.):
```python
from machine import Pin, PWM
import json
try:
# Motor driver pins
enable = PWM(Pin(14), freq=1000) # Speed (PWM)
in1 = Pin(26, Pin.OUT) # Direction
in2 = Pin(27, Pin.OUT)
# Forward at 75% speed
in1.value(1)
in2.value(0)
speed_pct = 75
enable.duty(int(speed_pct / 100 * 1023))
print("RESULT:" + json.dumps({
"direction": "forward",
"speed_pct": speed_pct,
}))
except Exception as e:
print("ERROR:" + str(e))
```
## Stepper Motor (ULN2003 Driver)
28BYJ-48 stepper with ULN2003 driver board:
```python
from machine import Pin
import time, json
try:
# ULN2003 input pins
pins = [Pin(p, Pin.OUT) for p in [25, 26, 27, 14]]
# Half-step sequence for smoother rotation
sequence = [
[1,0,0,0], [1,1,0,0], [0,1,0,0], [0,1,1,0],
[0,0,1,0], [0,0,1,1], [0,0,0,1], [1,0,0,1],
]
steps = 512 # ~90 degrees for 28BYJ-48
delay_ms = 2
for i in range(steps):
phase = sequence[i % len(sequence)]
for j, pin in enumerate(pins):
pin.value(phase[j])
time.sleep_ms(delay_ms)
# Turn off all coils
for pin in pins:
pin.value(0)
print("RESULT:" + json.dumps({"steps": steps, "delay_ms": delay_ms}))
except Exception as e:
# Clean up pins on error
for pin in pins:
pin.value(0)
print("ERROR:" + str(e))
```
## WS2812 / NeoPixel LED Strip
```python
from machine import Pin
from neopixel import NeoPixel
import json
try:
num_leds = 8
np = NeoPixel(Pin(5), num_leds)
# Set all LEDs to a color (R, G, B) — values 0-255
color = (0, 50, 0) # Dim green
for i in range(num_leds):
np[i] = color
np.write()
print("RESULT:" + json.dumps({
"num_leds": num_leds,
"color_rgb": list(color),
}))
except Exception as e:
print("ERROR:" + str(e))
```
Rainbow effect:
```python
from machine import Pin
from neopixel import NeoPixel
import time, json
try:
np = NeoPixel(Pin(5), 8)
def wheel(pos):
if pos < 85:
return (pos * 3, 255 - pos * 3, 0)
elif pos < 170:
pos -= 85
return (255 - pos * 3, 0, pos * 3)
else:
pos -= 170
return (0, pos * 3, 255 - pos * 3)
for cycle in range(3): # 3 rainbow cycles
for j in range(256):
for i in range(8):
np[i] = wheel((i * 32 + j) & 255)
np.write()
time.sleep_ms(20)
# Turn off
for i in range(8):
np[i] = (0, 0, 0)
np.write()
print("RESULT:" + json.dumps({"effect": "rainbow", "cycles": 3}))
except Exception as e:
print("ERROR:" + str(e))
```
## Buzzer / Piezo
Tone generation via PWM:
```python
from machine import Pin, PWM
import time, json
try:
buzzer = PWM(Pin(15))
# Play a melody (frequency in Hz, duration in ms)
melody = [(262, 200), (330, 200), (392, 200), (523, 400)] # C E G C5
for freq, duration in melody:
buzzer.freq(freq)
buzzer.duty(512) # 50% duty for audible tone
time.sleep_ms(duration)
buzzer.duty(0) # Silence between notes
time.sleep_ms(50)
buzzer.deinit()
print("RESULT:" + json.dumps({"melody_notes": len(melody)}))
except Exception as e:
try:
buzzer.deinit()
except:
pass
print("ERROR:" + str(e))
```Related Skills
find-skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
ht-skills
管理灏天文库文集和文档,支持新建文集、新建文档、查询文集/文档、更新文档、修改文档归属、管理文档层级。适用于 OpenClaw 自主写文章并上传、文集创建、文档入库、文档移动等场景。
web-skills-protocol
Auto-discover and use Web Skills Protocol (WSP) skills when interacting with websites. Use this skill whenever the user asks you to interact with, use, or perform actions on a website or web service — such as searching a site, placing an order, deploying an app, or calling a web API. Before scraping HTML or guessing at interfaces, check if the site publishes a skills.txt or agents.txt file that teaches you how to use it properly. If a website has complex elements (e.g., heavy JavaScript, interactive UIs), activating this skill can also help you understand the site's purpose and capabilities. Do NOT use for local file operations or non-web tasks.
clawdtm-skills
Review and rate Claude Code skills. See what humans and AI agents recommend.
micropython-skills/sensor
MicroPython sensor reading — DHT11/22, BME280, MPU6050, ADC, ultrasonic HC-SR04, photoresistor, generic I2C sensors.
micropython-skills/network
MicroPython networking — WiFi STA/AP, HTTP requests, MQTT pub/sub, BLE, NTP time sync, WebSocket.
micropython-skills/diagnostic
MicroPython device diagnostics — system info, I2C/SPI bus scan, pin state, filesystem, memory, performance benchmarks.
micropython-skills/algorithm
MicroPython on-device algorithms — PID controller, moving average, Kalman filter, state machine, task scheduler, data logger.
micropython-skills
Program and interact with embedded development boards (ESP32, ESP32-S3, ESP32-C3, ESP8266, NodeMCU, Raspberry Pi Pico, RP2040, STM32) through real-time REPL. This skill turns microcontroller hardware into an AI-programmable co-processor — read sensors, control actuators, flash firmware, diagnose devices, and deploy algorithms. Trigger when the user mentions any dev board or hardware interaction: ESP32, ESP8266, NodeMCU, Pico, 开发板, 板子, 单片机, 嵌入式, microcontroller, development board, sensor reading, GPIO, LED, motor, relay, I2C, SPI, UART, ADC, PWM, servo, DHT, BME280, temperature sensor, 传感器, 读传感器, 控制电机, 继电器, flash firmware, 烧录, 刷固件, 刷机, mpremote, MicroPython, IoT, MQTT, WiFi on board, 设备没反应, device not responding, or any task involving programming or controlling a physical microcontroller board.
unified-find-skills
Helps users discover and install agent skills from skills.sh, clawhub.com, and tessl.io. Use when the user asks to find a skill for a task, extend agent capabilities, or search for tools/workflows.
Skills for openclaw
World-class fullstack development skill covering frontend (React, Next.js, Vue, HTML/CSS/JS), backend (Node.js, Python/FastAPI, Django, Express), databases (PostgreSQL, MongoDB, Redis), APIs (REST, GraphQL), DevOps (Docker, CI/CD), and architecture design. Use this skill whenever the user asks to build, fix, review, architect, or debug ANY web application — frontend, backend, or full-stack.
Claude Skills 开发框架架构指导手册
## 1. 项目概述 (Overview)