Hi, I’m looking for the best way to monitor a numeric keypad from a PC and turn on or off a relay from my code.
I’m looking at possibly connecting a numeric keypad to an Arduino microcontroller (though I don’t yet know how), and then connecting it to the PC via USB.
Questions:
Is there an SDK available for interfacing with the Arduino microcontroller from the PC?
Can the Arduino be used to control a relay as well?
Is there a better product for this? Or perhaps a combination of microcontrollers that can work together to accomplish this?
Thank you,
Chris
Hi Chris,
Using an Arduino with the keypad can certainly work. Most keypads require a certain type of scanning of their outputs to detect all the buttons. Usually, the manufacturers do provide wiring diagrams and example code / libraries to do this / get you started.
A simple keypad would be RB-Dfr-97. Make sure to check the wiring in the third picture. Use that information in combination with this tutorial or this one to learn how to use the Keypad library (GitHub here).
As for interfacing an Arduino microcontroller board with a PC, simply connect it to the PC by USB. If your drivers are properly installed, it should create a VCP (Virtual COM Port). From there, you can use any serial interface software (Putty, the Serial Monitor in the Arduino IDE, etc.) or any modern programming language to access the COM port directly, thus enabling interaction.
Of course, you will need to decide on what kinda of data you will be sending and receiving from your Arduino board and the format it will use (i.e.: a protocol). It could be something as simple as: when a key is pressed, the Arduino transmit “~k”, where k is the key in ASCII and the computer can transmit back a 1/0 to turn on/off the relay. Some experimentation will be required here to determine what works best for you and your project.
As you can imagine, using the Arduino to control the relay is a great idea. It has plenty of I/Os to do both the keypad and one relay. You can browse our relay catalog here.
Sincerely,