Skip to content

Sensor: KEY MATRIX 4x4

Jaume Olivé Petrus edited this page Oct 30, 2017 · 7 revisions

Back to sensor blocks

Sensor information

What Comments
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
Read () from sensor key1
key2
key3
key4
key5
key6
key7
key8
key9
key10
key11
key12
key13
key14
key15
key16
1 = key down
0 = key up
Set () with value for sensor repeat 1 = enable repeat function, 0 = disable.
When enabled this sensor fires a callback when
you press and hold a key on the key matrix.
repeat delay When you press and hold a key on the key matrix,
the sensor fires a callback. The pause between pressing
the key and when it starts repeating is the repeat
delay, expressed in msecs.

Default value is 1500 msecs.
repeat rate After you press and hold down a key on the key matrix,
the key starts repeating once the repeat
delay expires. The speed at which it
repeats is the repeat rate, expressed
in msecs.

Default value is 500 msecs.
Callbacks? yes

Notes

  • This sensor requires 8 GPIO. We recommend to use an external GPIO with pull-ups like the PCA9505 chip.
  • This sensor performs a scan on the entire key matrix every 1 msec. You can find the operating principle in this article.
  • Hardware pull-ups are not required.
  • Many cheap key matrix don't include diodes for each key, so you may experiment ghosting and masking problems if you use these key matrix.
  • You can use key matrix with diodes with this sensor.

Back to sensor blocks

Clone this wiki locally