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
GPIO 2: L2
GPIO 3: L3
GPIO 4: L4
GPIO 5: H1
GPIO 6: H2
GPIO 7: H3
GPIO 8: 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 repeat 1 = enable repeat function. When enabled this sensor fires a callback when you hold a key down.
repeat delay If repeat function is enabled, the time in msecs that you must to hold a key down for start the repeat function. When this time expires the sensor fires a callback at the specified repeat rate time.
repeat rate The repeat rate in msecs.
Callbacks? yes

Code

km = sensor.attach("KEY_MATRIX_4_4", 40, 41, 42, 43, 44, 45, 46, 47)

km:callback(
   function(data)
      if (data.key1 == 1) then
	     print("key1")
	  end

      if (data.key2 == 1) then
	     print("key2")
	  end

      if (data.key3 == 1) then
	     print("key4")
	  end

      if (data.key4 == 1) then
	     print("key4")
	  end

      if (data.key5 == 1) then
	     print("key5")
	  end

      if (data.key6 == 1) then
	     print("key6")
	  end

      if (data.key7 == 1) then
	     print("key7")
	  end

      if (data.key8 == 1) then
	     print("key8")
	  end

      if (data.key9 == 1) then
	     print("key0")
	  end

      if (data.key10 == 1) then
	     print("key10")
	  end

      if (data.key11 == 1) then
	     print("key11")
	  end

      if (data.key12 == 1) then
	     print("key12")
	  end

      if (data.key13 == 1) then
	     print("key13")
	  end

      if (data.key14 == 1) then
	     print("key14")
	  end

      if (data.key14 == 1) then
	     print("key14")
	  end

      if (data.key16 == 1) then
	     print("key16")
	  end
   end
)
Clone this wiki locally