-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathblinkled.xlua
More file actions
30 lines (23 loc) · 845 Bytes
/
blinkled.xlua
File metadata and controls
30 lines (23 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
--[[
This Lua script creates a new blinking LED timer coroutine each time it runs.
Click the refresh button to create a new.
The timer object is free-floating since we are not referencing
(anchoring) the object. The created timer(s) will eventually be
collected by the Lua garbage collector.
Online timer example with documentation: https://tutorial.realtimelogic.com/Lua-Coroutines.lsp
Scroll down to Creating a Timer in Coroutine Mode
Timer documentation:
https://realtimelogic.com/ba/doc/?url=lua.html#ba_timer
The example uses GPIO #4. Connect an LED between GPIO 4 and ground.
--]]
local function blink()
local pin = esp32.gpio(4,"OUT")
while true do
trace"blink"
pin:value(true)
coroutine.yield(true) -- Sleep
pin:value(false)
coroutine.yield(true) -- Sleep
end
end
ba.timer(blink):set(1000)