summaryrefslogtreecommitdiff
path: root/mesecons_luacontroller/examples
diff options
context:
space:
mode:
Diffstat (limited to 'mesecons_luacontroller/examples')
-rw-r--r--mesecons_luacontroller/examples/clock.lua7
-rw-r--r--mesecons_luacontroller/examples/counter.lua11
-rw-r--r--mesecons_luacontroller/examples/rslatch.lua18
3 files changed, 36 insertions, 0 deletions
diff --git a/mesecons_luacontroller/examples/clock.lua b/mesecons_luacontroller/examples/clock.lua
new file mode 100644
index 0000000..262aac2
--- /dev/null
+++ b/mesecons_luacontroller/examples/clock.lua
@@ -0,0 +1,7 @@
+--Interrupt-Driven Clock
+--Continually pulses pin A, turning on/off once per second.
+
+if event.type == "program" or event.iid == "clock" then
+ port.a = not port.a
+ interrupt(1,"clock",true)
+end
diff --git a/mesecons_luacontroller/examples/counter.lua b/mesecons_luacontroller/examples/counter.lua
new file mode 100644
index 0000000..bbb974c
--- /dev/null
+++ b/mesecons_luacontroller/examples/counter.lua
@@ -0,0 +1,11 @@
+--LCD Counter (requires digilines)
+--Counts the number of pulses sent to pin A and displays the number on an LCD.
+--Connect the LCD over digilines and set the channel to "lcd"
+
+if event.type == "program" then
+ mem.count = 0
+elseif event.type == "on" and event.pin.name == "A" then
+ mem.count = mem.count + 1
+end
+
+digiline_send("lcd",tostring(mem.count))
diff --git a/mesecons_luacontroller/examples/rslatch.lua b/mesecons_luacontroller/examples/rslatch.lua
new file mode 100644
index 0000000..1257396
--- /dev/null
+++ b/mesecons_luacontroller/examples/rslatch.lua
@@ -0,0 +1,18 @@
+--R/S Latch
+--When S is active, Q turns on.
+--When R is active, Q turns off.
+--/Q is always the opposite of Q.
+
+--Pin Assignments:
+-- S: Pin A
+-- R: Pin B
+-- Q: Pin C
+--/Q: Pin D
+
+if pin.a then
+ port.c = true
+elseif pin.b then
+ port.c = false
+end
+
+port.d = not port.c