mbalmer ae1a443653 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.
2012-02-25 09:13:38 +00:00

29 lines
539 B
Lua

-- $NetBSD: gpio.lua,v 1.2 2012/02/25 09:13:38 mbalmer Exp $
require 'gpio'
print(gpio._VERSION .. ' - ' .. gpio._DESCRIPTION)
print(gpio._COPYRIGHT)
print()
g = gpio.open('/dev/gpio0')
local npins = g:info()
print('gpio0 has ' .. npins .. ' pins.')
for n = 0, npins - 1 do
print('pin ' .. n .. ': ' .. g:read(n))
end
local oldval = g:write(31, gpio.PIN_HIGH)
print('pin 31: ' .. oldval .. ' -> ' .. g:read(31))
oldval = g:toggle(31)
print('pin 31: ' .. oldval .. ' -> ' .. g:read(31))
g:write(31, gpio.PIN_LOW)
g:write(31, 5)