You must be logged in to reply.

Page 1 of 2 out of 13 messages.

Tech Talk with Gus 13 - Keypad Matrix

3 likes
Today, we'll be talking about 'Membrane Keypad Matrices'. How they work and how to use them in your projects.


https://youtu.be/ODBAEZfhWtU
Reply #1 — Posted 2yr ago
by Mr. John Smith | Legend | 42,263 exp
Reply #1 — Posted 2yr ago
by Mr. John Smith | Legend | 42,263 exp
So then, if I energize all the outputs and then use an interrupt on the input pins, when I press a button, I can then cycle through the outputs quickly to determine which element in the column was actually pushed? Can I do this instead of constantly poling the keypad?
Reply #2 — Posted 2yr ago
by Gus_ghielectroncs | Employee
Reply #2 — Posted 2yr ago
by Gus_ghielectroncs | Employee
@Mr. John Smith - in a deterministic environment yes that should work. I haven't tried it though.
Reply #3 — Posted 2yr ago
by mhectorgato | King | 37,168 exp
Reply #3 — Posted 2yr ago
by mhectorgato | King | 37,168 exp
Thanks for the videos, another thing to look forward to on Fridays!

Where is the code for this project? (it may be hidden in plain sight and I've missed it)
2 likes
Reply #4 — Posted 2yr ago
by Gus_ghielectroncs | Employee
Reply #4 — Posted 2yr ago
by Gus_ghielectroncs | Employee
@mhectorgato - will post when I get to my PC. It is the holidays and I am busy drinking Dancing
1 like
Reply #5 — Posted 2yr ago
by Mr. John Smith | Legend | 42,263 exp
Reply #5 — Posted 2yr ago
by Mr. John Smith | Legend | 42,263 exp
@Gus - Well don't drink too much; it looks like you're slimming down.
1 like
Reply #6 — Posted 2yr ago
by Bill_Wyo | Senior | 2,584 exp
Reply #6 — Posted 2yr ago
by Bill_Wyo | Senior | 2,584 exp
@Gus - Thanks Gus, good topic for me. I remember WBSimms (may not have that correct) put a project on codeshare that used interrupts to minimize the lines used. This looks like a candidate for that hardware/software. If there is a 3x4 and a 4x4 available there are probably more variations as well. Thank you again.
1 like
Reply #7 — Posted 2yr ago
by Gus_ghielectroncs | Employee
Reply #7 — Posted 2yr ago
by Gus_ghielectroncs | Employee
And here is the code

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHI.Pins;

namespace KeyMatrix
{
    public class Program
    {
        static Bitmap LCD = new Bitmap(480, 272);
        static Font fnt = Resources.GetFont(Resources.FontResources.Arial48);

        static void Print(string str)
        {
            LCD.Clear();
            LCD.DrawText(str, fnt, Microsoft.SPOT.Presentation.Media.Color.White, 200, 100);
            LCD.Flush();
        }
        public static void Main()
        {
            OutputPort Row1 = new OutputPort(FEZCobraIII.Gpio.D7, false);
            OutputPort Row2 = new OutputPort(FEZCobraIII.Gpio.D6, false);
            OutputPort Row3 = new OutputPort(FEZCobraIII.Gpio.D5, false);
            OutputPort Row4 = new OutputPort(FEZCobraIII.Gpio.D4, false);

            InputPort Col1 = new InputPort(FEZCobraIII.Gpio.D3, false, Port.ResistorMode.PullUp);
            InputPort Col2 = new InputPort(FEZCobraIII.Gpio.D2, false, Port.ResistorMode.PullUp);
            InputPort Col3 = new InputPort(FEZCobraIII.Gpio.D1, false, Port.ResistorMode.PullUp);
            InputPort Col4 = new InputPort(FEZCobraIII.Gpio.D0, false, Port.ResistorMode.PullUp);

            Print("Go!");

            while (true)
            {
                // First Row
                Row1.Write(false); Row2.Write(true); Row3.Write(true); Row4.Write(true);
                if (!Col1.Read())
                    Print("1");
                if (!Col2.Read())
                    Print("2");
                if (!Col3.Read())
                    Print("3");
                if (!Col4.Read())
                    Print("A");
                // Second Row
                Row1.Write(true); Row2.Write(false); Row3.Write(true); Row4.Write(true);
                if (!Col1.Read())
                    Print("4");
                if (!Col2.Read())
                    Print("5");
                if (!Col3.Read())
                    Print("6");
                if (!Col4.Read())
                    Print("B");
                // Third Row
                Row1.Write(true); Row2.Write(true); Row3.Write(false); Row4.Write(true);
                if (!Col1.Read())
                    Print("7");
                if (!Col2.Read())
                    Print("8");
                if (!Col3.Read())
                    Print("9");
                if (!Col4.Read())
                    Print("C");
                // Forth Row
                Row1.Write(true); Row2.Write(true); Row3.Write(true); Row4.Write(false);
                if (!Col1.Read())
                    Print("*");
                if (!Col2.Read())
                    Print("0");
                if (!Col3.Read())
                    Print("#");
                if (!Col4.Read())
                    Print("D");


                Thread.Sleep(20);
            }
        }
    }
}
2 likes
Reply #8 — Posted 2yr ago
by suitable1 | Master | 7,672 exp
Reply #8 — Posted 2yr ago
by suitable1 | Master | 7,672 exp
Gus says:

And here is the code

Wow, sober after just a couple of days!
Reply #9 — Posted 2yr ago
by Mike | Superhuman | 82,265 exp
Reply #9 — Posted 2yr ago
by Mike | Superhuman | 82,265 exp
No bounce issues with the above code? Shocked

Page 1 of 2 out of 13 messages.

You must be logged in to reply.