![]() This is a "matrix membrane keypad". I have seen 4x4 and 3x4. They are flexible and under $2. The advantage to them is they are more inputs with fewer wires (16 or 12 depending on which you use). There is a wire for each row and each column. How you detect which button is pressed is by using code to scan each row/column combination. So a 3x4 needs 7 wires and a 4x4 needs 8. Which also means, if you need 5 or fewer inputs, just use arcade buttons...(though those would cost more than this). You can put your own stickers over the "buttons" to have special words. The way I have found & figured to code this is to set each row HIGH (digital write) one at a time, then READ each column to see which goes high. pseudocode : Digital write row 1 (whichever pin that is attached to) HIGH if column 1 = HIGH (digital read) then do something if column 2 = HIGH then do something else if column 3 = HIGH then do something different if column 4 - HIGH then do some other thing Digital write row 2 HIGH ... more similar statements for row 2, row 3 , row 4. Could be a good use for a function - "scan keys" I am thinking we have to be careful picking which 8 pins on the micro:bit you use to avoid conflicts. Also, you need an expansion board that gives you access to 8 pins. As well as appropriate dupont wires to make connections. This made me begin to look into arrays in makecode.com (under Advanced) A magic 8 ball is something that uses an array or list of phrases. Shake it and it displays a random item from the list. (could do this with micro:bit and an OLED) You can put a whole bunch of musical notes in an array/list, then use 1 command to play them all, one after the other. But this only works if you play each note for the same duration. The old way would be to have a play command for each note. You might need someplace to store something like a password and someplace to put inputs one at a time...which is an array (or list). Here is a little twist, you dont compare a whole array or a list to see if it matches another, you have to compare EACH element, one at a time. If you try to compare "list1" to "list2"...i think it just looks at the locations, not what is in them So you have to compare "list1 item1" to "list2 item2"...and so on. It is just a matter of choosing the correct code....and maybe a "for loop" or "repeat loop"...AND a nice embedded boolean... "if these two are = AND these two are = AND these 2 are equal....." {i'll do more on that later} So, what project do you have that could use 6-16 possible inputs? -A combination lock/numeric password could be one -Maybe playing music...16 notes? I wonder about a way to do octaves...though I assume you cannot press two of these buttons at the same time, so I would need a second one or arcade buttons to pick the octave. You dont HAVE to use all 16 keys on a 4x4...you could just wire 2 rows. Just some intro thoughts...more later when I make some videos.
0 Comments
Your comment will be posted after it is approved.
Leave a Reply. |
Archives
December 2022
Categories |