Leonardo / Pro Micro

From sudomod
Revision as of 22:48, 11 October 2016 by Chaosratt (Talk | contribs) (fixed random link to bad image.)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Leonardo Pro Micro.png

Description

The cheap alternative to the Teensy LC.

official Website

https://www.sparkfun.com/products/12640

Guide/How To

The user IAmOrion wrote a guide on how to use the board. It can be found in the forum.

Guide for dummies

For people who are in no way experienced in programming an Arduino there's a detailed guide:

  • Download and install the Arduino IDE from the official website
  • Connect your pro micro to your PC via micro-USB cable (a red LED should light up)
  • Open the Arduino software, click on 'tools' and select the correct Board ("Arduino Leonardo") and Port (it should display a COM-Port with the description (Arduino Leonardo) after the Com-Port number)
  • Now you can Copy/Paste the following code into the provided area:
    #include <Keyboard.h>
    #define BUTTONS 15
    int pin_arr[]={2,4,3,5,14,16,9,8,A0,A1,6,7,A2,A3,15};
    int keycode_arr[]={218,217,216,215,128,130,32,129,122,176,53,49,112,177,179};
    // UP,DOWN,LEFT,RIGHT,LEFT-CTRL (Button 1), LEFT-ALT (Button 2),SPACEBAR (Button 3), LEFT-SHIFT (Button 4), Z (Button 5), ENTER (Button 6) (Enter instead of X so can use with other RPi things like raspi-config), Coin/Credit, 1P Start, P (Pause), ESC, TAB
    int key_state[BUTTONS];
    
    void setup() {
      Keyboard.begin();
      for (int i=0;i<BUTTONS;i++)
      {
        pinMode(pin_arr[i], INPUT_PULLUP);
        key_state[i] = digitalRead(pin_arr[i]);
      }
    }
    
    void loop() {
      for (int i=0;i<BUTTONS;i++)
      {
        key_state[i]=digitalRead(pin_arr[i]);
        if (key_state[i]==LOW) {
          Keyboard.press(keycode_arr[i]); if (keycode_arr[i] == 49) { delay(100); }
        } else {
          Keyboard.release(keycode_arr[i]);
        }
      } 
    }
  • At last, check and upload the code by clicking the according buttons. After this, a green LED should light up additionally to the red one and your PC should recognize a new Keyboard device.
  • Done. You can test your setup now by connecting one of the Pins on the pro micro to ground and see if the according keyboard signal arrives at your PC.

Details

Price

~3€

Chip

ATmega32u4

I/O Pins

16 (18)

Size

~33x18mm

Buy it

aliexpressbanggoodamazon.comamazon.de