1

I'm trying to wire up a silly little keyboard using hall effect sensors and magnets in a glove. The idea being only I can use the keyboard since I'll have the glove.

The sensors are 3 pin, (vcc, gnd, and an output that sends 5v out when a magnetic field is present. I don't have anywhere near enough pins on the teensy for all the sensors. Could I just use several port expanders? Are there issues with using 4 or 5 at once? How many keys could be pressed at a time?

Is there a better option than all those expanders?

Also I know that this keyboard will be ugly and completely impractible to use regularly, but I thought it would fun to show off.

2

[Completely rewritten answer]
That seems fun. But why 65 keys ? with 64 keys it is easier.

You have to test the sensitivity of the hall switches with the magnets to know how far apart the keys must be. Perhaps they only work with strong magnets or perhaps a number of them are activated when the glove is near.

With hall switches, there are 65 digital signals from the sensors.
The most common way to create more digital inputs is to use shift registers. For example with the 74HC165. Nick Gammon has the best tutorial of the 74HC165 with daisy-chain. There is also an example is with the CD4021 and the ShiftIn function, but the 74HC165 is mostly used.
The shift registers can be daisy-chained, they are made for that.

Your AH1807 has a open-drain output. That means you need 65 pullup resistors.
It is not possible to connect all the outputs and turn them on one by one, since it requires 150ms to wake up.

Another option is using multiplexers. It can be used for analog and for digital signals. For example with four 16-to-1 multiplexers you can create 64 inputs going to 4 pins. The best multiplexer tutorial is once again written by Nick Gammon.

With four analog multiplexers of 16-to-1 you would require only 4 pullup resistors after the multiplexer. I think it is better to use a resistor per hall sensor (65 pullup resistors).

When using reed switches (those tiny glass tubes, used in house alarms), they can be set in a matrix/grid with rows and columns and the Keypad library. For example 10*7 requires 17 pins. The Keypad library allows that multiple keys are pressed at the same time.

  • I've seen that tutorial and read a little bit on using a matrix for keyboards. If I'm not mistaken, with a physical switch, it pulls the columns to low and rows to high and has 2 connectors one for rows and one for columns. The sensor I have only has one output leg so all my columns and rows would be connected to the same output leg right? – Oe- Jul 2 '17 at 8:37
  • Oops, I might have made a big mistake. I was thinking about reed switches. Can you tell the type of the hall switches ? Perhaps I will remove my answer. – Jot Jul 2 '17 at 8:39
  • This is the sensor in question. digikey.com/product-detail/en/diodes-incorporated/AH1807-P-B/… – Oe- Jul 2 '17 at 8:56
  • Wow, thanks for the detailed response. It doesn't have to be 65, I can get it to 64 I'm sure. I'll read both of those tutorials and see which one works best. I'll see if I can find some Reed switches to play with too, that way I could use some of the existing firmware for keyboards. – Oe- Jul 2 '17 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.