Skip to content

KEY MATRIX 4x4

Jaume Olivé Petrus edited this page Sep 17, 2017 · 13 revisions

Specification

What Comments
Identifier KEY_MATRIX_4_4
Interface 8 GPIO GPIO 1: L1
L2
L3
L4
H1
H2
H3
H4

Lx: columns
Hx: rows
Provides key1
key2
key3
key4
key5
key6
key7
key8
key9
key10
key11
key12
key13
key14
key15
key16
1 = key down
0 = key up
Properties none
Callbacks? yes

Code

-- Attach switch to GPIO26
s = sensor.attach("PUSH_SWITCH", pio.GPIO26)

-- Register a callback. Callback is executed when some sensor property changes.
s:callback(
   function(data)
      if (data.on == 1) then
         print("on")
      elseif (data.on == 0) then
         print("off")
      end
   end
)
Clone this wiki locally