summaryrefslogtreecommitdiff
path: root/share/examples/lua
diff options
context:
space:
mode:
authormbalmer <mbalmer@NetBSD.org>2012-02-25 09:13:38 +0000
committermbalmer <mbalmer@NetBSD.org>2012-02-25 09:13:38 +0000
commitd56bb808e8b6f449a05aafe7104b27059619fe49 (patch)
treebc5ffc3085a9692ab0490f0e9a9cf92fe646f761 /share/examples/lua
parent0d52f63acb1a75faf1fd0d993b5369ff707b03c8 (diff)
GPIO pins are 0 based when accessed from Lua, not 1 based like Lua usually
is. The pulse() has been removed, use gpiopwm(4) for that.
Diffstat (limited to 'share/examples/lua')
-rw-r--r--share/examples/lua/gpio.lua19
1 files changed, 8 insertions, 11 deletions
diff --git a/share/examples/lua/gpio.lua b/share/examples/lua/gpio.lua
index 4e450c454c9..af796c88097 100644
--- a/share/examples/lua/gpio.lua
+++ b/share/examples/lua/gpio.lua
@@ -1,4 +1,4 @@
--- $NetBSD: gpio.lua,v 1.1 2011/10/15 12:58:43 mbalmer Exp $
+-- $NetBSD: gpio.lua,v 1.2 2012/02/25 09:13:38 mbalmer Exp $
require 'gpio'
@@ -12,20 +12,17 @@ local npins = g:info()
print('gpio0 has ' .. npins .. ' pins.')
-for n = 1, npins do
+for n = 0, npins - 1 do
print('pin ' .. n .. ': ' .. g:read(n))
end
-local oldval = g:write(32, gpio.PIN_HIGH)
-print('pin 32: ' .. oldval .. ' -> ' .. g:read(32))
+local oldval = g:write(31, gpio.PIN_HIGH)
+print('pin 31: ' .. oldval .. ' -> ' .. g:read(31))
-oldval = g:toggle(32)
-print('pin 32: ' .. oldval .. ' -> ' .. g:read(32))
+oldval = g:toggle(31)
+print('pin 31: ' .. oldval .. ' -> ' .. g:read(31))
-g:pulse(32, 1, 50)
-g:write(1, gpio.PIN_LOW)
+g:write(31, gpio.PIN_LOW)
-g:write(32, gpio.PIN_LOW)
-
-g:write(32, 5)
+g:write(31, 5)