Difference between revisions of "Leonardo / Pro Micro"

From sudomod
Jump to: navigation, search
(Details)
(added detailed guide for dummies)
Line 8: Line 8:
 
===Guide/How To===
 
===Guide/How To===
 
The user IAmOrion wrote a guide on how to use the board. It can be found in the [http://sudomod.com/forum/viewtopic.php?f=8&t=612 forum].
 
The user IAmOrion wrote a guide on how to use the board. It can be found in the [http://sudomod.com/forum/viewtopic.php?f=8&t=612 forum].
 +
 +
==Guide for dummies==
 +
For people who are in no way experienced in programming an Arduino there's a detailed guide:
 +
<ul>
 +
<li>Download and install the Arduino IDE [https://www.arduino.cc/en/Main/Software from the official website]</li>
 +
<li>Connect your pro micro to your PC via micro-USB cable (a red LED should light up)</li>
 +
<li>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)</li>
 +
<li>Now you can Copy/Paste the following code into the provided area:
 +
<syntaxhighlight>
 +
#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]);
 +
    }
 +
  }
 +
}</syntaxhighlight></li>
 +
<li>at last, check and upload the code by clicking the according buttons</li>
 +
</ul>
 +
 
===Details===
 
===Details===
 
{| class="wikitable" style="width:25%"
 
{| class="wikitable" style="width:25%"

Revision as of 17:32, 2 October 2016

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

Details

Price

~3€

Chip

ATmega32u4

I/O Pins

16 (18)

Size

~33x18mm

Buy it

aliexpressbanggoodamazon.comamazon.de