Example 2: LED Blink
About 1 min
Example 2: LED Blink
Experiment Overview
Achieve LED blinking by periodically toggling GPIO output state. In FastBee, you can use the peripheral execution timer trigger combined with GPIO toggle actions to achieve this without writing code.
Hardware Wiring
| Board Label | GPIO Pin | Connected Device |
|---|---|---|
| D1 | GPIO15 | LED (active low) |
Use any LED, this example uses D1 (GPIO15).
JSON Configuration Example
{
"peripherals": [
{
"id": "led_blink",
"name": "LED Blink",
"type": 12,
"enabled": false,
"pins": [15],
"params": {
"initialState": 1
}
}
]
}Peripheral Execution Linkage
Scenario: Timed LED Blink (Timer Trigger)
Function: Automatically toggle LED state every 500ms for blinking effect
Web Interface Configuration Steps
Step 1: Create Rule
- Click left menu Peripheral Configuration → Switch to Peripheral Execution Management tab
- Click New Rule button
- Fill in basic configuration:
- Rule Name:
LED Periodic Blink - 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 0.5Execute every 0.5 seconds (500ms)
Step 3: Configure Action
Click Add Action button
Fill in action configuration:
Field Value Description Action Type Select Toggle Level Flip GPIO state Target Peripheral Select led_blinkLED to control Click Save button
Execution Flow:
Every 500ms
↓
Read led_blink current state
↓
Invert: HIGH→LOW or LOW→HIGH
↓
LED on/off toggledAdjustable Blink Frequency
Modify Interval Seconds to change blink speed:
| Interval Value | Blink Effect | Use Case |
|---|---|---|
0.1 | Fast blink (100ms) | Emergency alarm |
0.5 | Normal blink (500ms) | Status indication |
1.0 | Slow blink (1 second) | Low power hint |
Notes
- Timer Precision: ESP32 timer precision is ~1ms, intervals below 10ms may be unstable
- Multi-LED Blink: You can add multiple gpio_toggle actions in the same rule
- Stop Blinking: Disable the peripheral execution rule to stop
- gpio_toggle: Automatically reads current pin state and inverts it, no need to track state
