• 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

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.

McDonald’s Gift Voucher From Line

Thanks @LINEMalaysia for sending this RM10 McDonald’s gift voucher to me! You can get this when you are new user and actively use LINE within a specified period.

McDonald's gift certificate from LINE

LINE is one of the social networking application I use frequently recently. To me, I don’t use mainly for social networking but more on connecting to the merchants that I’m interested in to find out deals and freebie :)

 

Electronics Project – Raspberry Pi + Attiny85 + LCD 1620

I always want to start an electronic project that build a home automation system but I don’t have much time. Don’t have time is just a bad excuse. So to make thing starts, I start buying electronic components and devices that I need and trying them one by one.

[Read more…]

#MH370 Live News

Probably you have already heard about the Malaysia Airline plane, MH370 mysteriously went missing in the air last Saturday. MH370 went missing for four days with 239 people on board and the search is still in progress. There are many hoax and inaccurate information being circulate around the social media and blogs.

MH370

You can actually get the latest updates on-line from Astro Awani Live TV: http://english.astroawani.com/videos/live or visit the live update blog from theguardian.com: http://www.theguardian.com/world/blog/2014/mar/11/malaysia-airlines-mh370-search-refocused-on-malacca-straits-live-updates

You can also help to search the missing plane using the satellite map at http://www.tomnod.com/nod/challenge/malaysiaairsar2014. The crowdsourced effort that is being spearheaded by Digital Globe requires users to help go through 1200 square miles of ocean, and tag any suspicious objects that could lead SAR teams to the location.

You can also see what people talking about the MH370 case at twitter with hashtag #MH370 or #PrayforMH370.

Pray hard for them!

Please come back MH370, we are waiting for you!

Malaysia Air Pollution Index (API) And Survial Guide

The haze hits Malaysia again. Several areas in Malaysia, including Selangor and Sembilan are reaching unhealthy level. With the hot weather, water disruption and no raining for a long time, make the haze even more worse.

Haze in Malaysia

The main cause of the haze is the open burning in Indonesia’s Riau recently. According to the National Disaster Mitigation Agency, about 7,972ha of land and forests have been destroyed by fires in the province. The smoke fire has caused many people in the province to suffer various respiratory problems.

To monitor the haze condition, Google has recently launched a Southeast Asia (SEA) Haze Crisis Map for the public to keep an eye on the air quality levels.

Survival Guide

The haze can pose serious health hazard, especially to those with a history of respiratory illness. Other than respiratory illness, it can also affect the throat, eyes and skin. Below are some guides to survives throughout these haze-days:

Stay indoor

Stay indoor as much as possible. Stay inside your house or in a building with air-conditioned or air purifier. Do not go out for an outdoor activity. Make sure your windows and ventilation outlets at home are closed properly.

Drink more water

Drink at least 2 litres of water a day to stay hydrated. Stay away from drinks that can cause dehydration. For instance, alcohol and coffee.

Bring along instant fixes

Always make sure to have these items in your bag: face mask, eye drops, water bottle, tissue, wet wipes. These will be your instant fixes in case of red eyes, scratchy throat and trouble with breathing.

Monitor API

Keep yourself updated on the haze. Check the pollution index before you go out from your home, be it to work or to travel to other states. You can always refer to the local news paper or the Department of Environment (DOE) websites which updates on every two hours. You can also check the API on Google’s Haze Crisis Map.

Consult the doctor

Always seek for the doctor immediately if you are feeling uncomfortable, especially if you are having difficulty in breathing. Always brings your medical solutions during the haze period if you are having breathing or skin problems.

The haze problem is not something we can stop immediately, what we can do is to protect ourself and loved ones from health issues. Hope everyone can stay healthy throughout these haze-days.

« Previous Page
Next Page »

Email News Letter

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

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

LED Downlight

Troubleshooting A Flickering LED Downlight

February 13, 2016 00:29 By Sze Hau

Repair A Broken iPhone Lightning Cable

January 30, 2016 00:54 By Sze Hau

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

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

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