input from keypad and microcontroller

satanas

satanas

@satanas-wIiiPN Oct 21, 2024
Hi all,😁

can you guys help me with: how to input a value from a keypad (say a keypad having 4 numbers; 1,2,3 and 4) into a microcontroller and the latter reads the number entered?

e.g. i want the microcontroller to know that my system must shutdown when the bump sensor reads '2', i.e it hits something twice. So when i pressed the key '2', the microcontroller gets the value '2' and will compare it with the bump count. But i don't know how to do it.😕

i am thinking of using 4 different switches, each defining numbers 1 to 4. but this would occupy 4 ports.. so guys can this be done using ONLY ONE PORT? 😒

please reply soon.

regards,
Satanas

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • reachrkata

    reachrkata

    @reachrkata-FOcqhH Feb 27, 2010

    Sure can. You can do it with a single ADC port.

    Connect the ADC port to the supply via a 47k pull-up (say).
    Next, connect different pull-downs to the same port through the 4 keys.
    For example, Connect the ADC port to GND via a 1K and Key 1.
    Again connect the ADC port to GND via a 2K and Key 2.... and so on.

    When no key is pressed, the ADC detects Vcc. When Key 1 is pressed, the ADC detects the voltage due to potential divide of 47k and 1k.
    ..... and so on.

    -Karthik.
  • satanas

    satanas

    @satanas-wIiiPN Feb 27, 2010

    Hi Karthik,

    thanks for the tip.. i will try it right away..

    cheerz.

    regards.
    satanas
  • satanas

    satanas

    @satanas-wIiiPN Mar 1, 2010

    Hi,

    i tried it but things are not working.. can you provide me with the circuit please-resistors values? the supply is 5V and am sure i did something wrong.. so please help me.. i have limited time. i would be very grateful to you guys..

    regards,
    satanas
  • reachrkata

    reachrkata

    @reachrkata-FOcqhH Mar 1, 2010

    Perhaps this clarifies everything -

    [​IMG]
    -Karthik
    😁
  • Ashraf HZ

    Ashraf HZ

    @Ash Mar 1, 2010

    In all honesty, I never thought of that kind of approach before 😛
  • reachrkata

    reachrkata

    @reachrkata-FOcqhH Mar 5, 2010

    No sweat Ash !! i too learnt it only in my company !!!

    -Karthik
    😁