Example 3: LED Flowing Light
Experiment Overview
Use multiple GPIO output pins and a command-script action to turn LEDs on and off in sequence.
Hardware Wiring
| Board Label | GPIO Pin | Connected Device |
|---|---|---|
| D1 | GPIO15 | LED1 (active low) |
| D2 | GPIO2 | LED2 (active low) |
| D3 | GPIO0 | LED3 (active low) |
| D4 | GPIO4 | LED4 (active low) |
JSON Configuration Example
json
{
"peripherals": [
{
"id": "flow_led1",
"name": "Flow LED-1",
"type": 12,
"enabled": false,
"pins": [15],
"params": { "initialState": 1 }
},
{
"id": "flow_led2",
"name": "Flow LED-2",
"type": 12,
"enabled": false,
"pins": [2],
"params": { "initialState": 1 }
},
{
"id": "flow_led3",
"name": "Flow LED-3",
"type": 12,
"enabled": false,
"pins": [0],
"params": { "initialState": 1 }
},
{
"id": "flow_led4",
"name": "Flow LED-4",
"type": 12,
"enabled": false,
"pins": [4],
"params": { "initialState": 1 }
}
]
}Peripheral Execution Linkage
Scenario: Timed Running Light (Timer Trigger + Command Script)
Function: Run the rule every 5 seconds and switch LEDs every 300 ms inside the script
Web Interface Configuration Steps
Step 1: Create Rule
- Click Peripheral Execution in the left menu
- Click New Rule button
- Fill in basic configuration:
- Rule Name:
LED Running Light - Report Data: ❌ Disable
- Enabled: ✅ Enable
- Rule Name:
Step 2: Configure Trigger
Click Add Trigger button
Fill in trigger configuration:
Field Value Description Trigger Type Select Timer Trigger Execute at time intervals Timer Mode Select Interval Timer Execute every X seconds Interval Seconds 5Run one cycle every 5 seconds so executions do not overlap
Step 3: Configure Action
Click Add Action button
Fill in action configuration:
Field Value Description Action Type Select Command Script Execute PERIPH/DELAY sequence Script Content See code block below Running light logic
Script Content:
PERIPH flow_led1 LOW
DELAY 300
PERIPH flow_led1 HIGH
PERIPH flow_led2 LOW
DELAY 300
PERIPH flow_led2 HIGH
PERIPH flow_led3 LOW
DELAY 300
PERIPH flow_led3 HIGH
PERIPH flow_led4 LOW
DELAY 300
PERIPH flow_led4 HIGH- Click Save button
Execution Flow:
Triggered once every 5 seconds
↓
Turn on LED1 (LOW)
↓
Delay 300ms
↓
Turn off LED1 (HIGH)
↓
Turn on LED2 → Delay → Turn off
↓
Turn on LED3 → Delay → Turn off
↓
Turn on LED4 → Delay → Turn off
↓
Wait for the next cycleScript Reference
| Command | Description | Example |
|---|---|---|
PERIPH | Control peripheral level | PERIPH flow_led1 LOW |
DELAY | Delay (milliseconds) | DELAY 300 |
Tip: Reorder the
PERIPHcommands for a back-and-forth pattern. Add rule triggers and actions when conditional linkage is required.
Notes
- Script Limit: One script is limited to 1024 characters and 50 commands
- Light Interval: This example uses 300 ms; adjust it as needed, but one
DELAYcannot exceed 10 seconds - GPIO0 Constraint: Do not pull GPIO0 LOW during boot, otherwise it enters download mode
- Extension: Reorder commands for a back-and-forth pattern; random values expand only in
LOGandMQTTcommands

