• Home
  • About

szehau's weblog

Life, Internet, Software, Gadgets, Programming and Investments

  • life log
  • internet
  • programming
  • software
  • working holiday
  • gadget
  • project

Electronics Project – Simple Card Read Keyboard Emulator Using Arduino Pro Micro

April 21, 2015 19:32 by Sze Hau Leave a Comment

I bought this little thing – Micro Pro – from the China website. I think it is a clone or compatible to the SparkFun’s Micro Pro. It is easy to use. It comes with USB that you can use it to program the microcontroller or let the microcontroller to communicate with your computer. You can simply use the Keyboard library from the Arduino to program a keyboard emulator: http://www.arduino.cc/en/Reference/KeyboardPrintln.

Arduino Pro Micro - Simple Card Read Keyboard Emulator

Below is the specification of the microcontroller:

  • ATmega32U4 running at 5V/16MHz
  • Supported under Arduino IDE v1.0.1
  • On-Board micro-USB connector for programming
  • 4 x 10-bit ADC pins
  • 12 x Digital I/Os (5 are PWM capable)
  • Rx and Tx Hardware Serial Connections

Below is the source code for my program that emulates a card reader keyboard:

int button = 2;

void setup() {
  pinMode(button, INPUT_PULLUP); // Use internal pull up resistor
  Keyboard.begin();
}

void loop() {
  int pressed = digitalRead(button) == 0;
  if (pressed) delay(500);
  if (pressed && digitalRead(button) == 0) {
    Keyboard.println("111111");
    delay(2000);
  } else if (pressed) {
    Keyboard.println("222222");
    delay(2000);
  }
}

If you press the button once quickly, the microcontroller will send the card data string “111111” (with new line) to your PC via USB HID keyboard driver.

If you press the button once a little bit longer (around 500 milliseconds), the microcontroller will send the card data string “222222” (with new line) to your PC via USB HID keyboard driver.

I’m using a internal pull up resistor in the microcontroller itself so that I do not need to have a external resistor to pull up or down the floating digital pin (when used as input). When the input pin is pull down (when the switch is pressed) to the ground, the digitalRead will return zero value and otherwise it will be value one.

It’s so simple that you can make your program ready within minutes. Of course, you must first make sure the programming environment (IDE, the COM port of the Micro Pro is properly installed) is ready.

More from my site

  • Electronics Project – Raspberry Pi + Attiny85 + LCD 1620Electronics Project – Raspberry Pi + Attiny85 + LCD 1620
  • Repair A Broken iPhone Lightning CableRepair A Broken iPhone Lightning Cable
  • One Watt LED Night LightOne Watt LED Night Light
  • It’s a Friday or It’s a Monday?It’s a Friday or It’s a Monday?
  • Maybank2u’s TAC request service is really badMaybank2u’s TAC request service is really bad
  • Snow Wolf Lake Starts TonightSnow Wolf Lake Starts Tonight

Filed Under: gadget, programming, project Tagged With: Arduino, electronic, home automation

About Sze Hau

Geek. Love programming. Coffee addicted. Married with a child. Working towards financial freedom.

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Email News Letter

Sign up to receive updates daily and to hear what's going on with us

  • Facebook
  • Google+
  • Instagram
  • Twitter

More Posts

5 Essential Things You Need To Have At Your Home During The COVID-19 Pandemic

June 1, 2021 22:15 By Sze Hau Leave a Comment

LED Downlight

Troubleshooting A Flickering LED Downlight

February 13, 2016 00:29 By Sze Hau Leave a Comment

Repair A Broken iPhone Lightning Cable

January 30, 2016 00:54 By Sze Hau Leave a Comment

Sponsored Links

Blog Network

  • Personal Fincance Personal Finance – Personal Money Tips, Stock Investment, Small Business and Make Money Online
  • Snippet IT Information technology news, ideas and experiences and opinions

szehau’s weblog

szehau is a software programmer that has strong interest in the world of programming and Internet. He is graduated in University of Malaya, Malaysia with a Bachelor’s degree in Software Engineering. He draws on his passsion for web programming to share with others how to build a successful websites.

Recent

  • 5 Essential Things You Need To Have At Your Home During The COVID-19 Pandemic
  • Troubleshooting A Flickering LED Downlight
  • Repair A Broken iPhone Lightning Cable
  • New Gadget – MacBook Pro with Retina Display (2015)
  • One Watt LED Night Light

Search

Tags

adsense advertisement baby blog blogtal Canon EOS 400D Chinese New Year Christchurch CNY DiGi electronic Facebook FBM Flickr Flickr Uploadr Google Google Maps Google Search Results Google Webmaster Central H1N1 income tax investment joke KLCI KLSE Lake Tekapo Maxis Maybank2u Motueka movie mutual funds New Zealand PC Fair 2009 Queenstown restaurant for dinner sharing stock trackback travel Twitter unit trust visa wordpress wordpress plugin working holiday

Copyright © 2025 · Magazine Pro Theme on Genesis Framework · WordPress · Log in