Arduino Pro (Leonardo Micro)
- RxBrad
- Posts: 278
- Joined: Fri Jul 22, 2016 9:10 am
- Has thanked: 125 times
- Been thanked: 160 times
- Contact:
Re: Arduino Pro (Leonardo Micro)
I'm seeing almost 0.5 seconds of input lag with this PCB that I don't see when using a regular keyboard hooked up to the same USB hub on my Pi0. It's basically unplayable. Anyone else having this problem??
EDIT: So, apparently I programmed it wrong. The red light on the Leonardo Micro was on the entire time it was plugged in. It shouldn't do that.
I flashed it with the alternate programming mode in the Arduino software (the one not using programmer), and it worked. The red light only turns on when you push a button on the GBZ.
EDIT: So, apparently I programmed it wrong. The red light on the Leonardo Micro was on the entire time it was plugged in. It shouldn't do that.
I flashed it with the alternate programming mode in the Arduino software (the one not using programmer), and it worked. The red light only turns on when you push a button on the GBZ.
Last edited by RxBrad on Fri Sep 09, 2016 8:06 am, edited 1 time in total.
Re: Arduino Pro (Leonardo Micro)
No... i have been playing fine... :/RxBrad wrote:I'm seeing almost 0.5 seconds of input lag with this PCB that I don't see when using a regular keyboard hooked up to the same USB hub on my Pi0. It's basically unplayable. Anyone else having this problem??
-
- Posts: 392
- Joined: Thu Jun 09, 2016 4:17 am
- Location: uk
- Has thanked: 76 times
- Been thanked: 51 times
Re: Arduino Pro (Leonardo Micro)
i also am struggling with where to connect my usb, does anyone have an answer to this yet?Raizan wrote:Hey, can someone tell me where shoud i connect the usb pads from the pi zero (from the usb hub) to the arduino pro board?
On the teensy lc you connect it to VCC D- D+ GND but the pro micro uses other...
Thank you
thanks
Check out my modding and repair channel of retro and modern consoles:
https://www.youtube.com/channel/UCFz7yW ... GtQ/videos
https://www.youtube.com/channel/UCFz7yW ... GtQ/videos
Re: Arduino Pro (Leonardo Micro)
I ended up stripping a micro usb cable and connect the nicro usb port to the arduino pro and the cables to the usb hub...Lpoolm wrote:i also am struggling with where to connect my usb, does anyone have an answer to this yet?Raizan wrote:Hey, can someone tell me where shoud i connect the usb pads from the pi zero (from the usb hub) to the arduino pro board?
On the teensy lc you connect it to VCC D- D+ GND but the pro micro uses other...
Thank you
thanks
-
- Posts: 392
- Joined: Thu Jun 09, 2016 4:17 am
- Location: uk
- Has thanked: 76 times
- Been thanked: 51 times
Re: Arduino Pro (Leonardo Micro)
Thanks, I saw your post, hoping there was a better way but maybe my only option!Raizan wrote:I ended up stripping a micro usb cable and connect the nicro usb port to the arduino pro and the cables to the usb hub...Lpoolm wrote:i also am struggling with where to connect my usb, does anyone have an answer to this yet?Raizan wrote:Hey, can someone tell me where shoud i connect the usb pads from the pi zero (from the usb hub) to the arduino pro board?
On the teensy lc you connect it to VCC D- D+ GND but the pro micro uses other...
Thank you
thanks
Check out my modding and repair channel of retro and modern consoles:
https://www.youtube.com/channel/UCFz7yW ... GtQ/videos
https://www.youtube.com/channel/UCFz7yW ... GtQ/videos
- Perifferal
- Posts: 6
- Joined: Fri Sep 09, 2016 5:24 pm
- Location: Netherlands
- Has thanked: 3 times
- Contact:
Re: Arduino Pro (Leonardo Micro)
I am wanting to start with making a GBZ, including L1, L2, R1, R2 buttons and 1 analog stick. Seeing the amount of inputs the micro can handle, this should be possible: 14 buttons and 2 analog (X and Y-axis). I am just wondering whether the analog stick will actually work or not? Is it seen as a keypress, or is there a way to set it up as an actual analog stick? Any ideas?
Re: Arduino Pro (Leonardo Micro)
You can make a joystick with the analog inputs.
Look at this guide
Add USB Game Controller to Arduino Leonardo/Micro
Does anyone experience missed key presses? Not every press is recognized. I don't know if it's the hub's fault.
Edit:
I made a new sketch which doesn't use the slow digitalRead commands. I also reduced power consumption using the power reduction registers.
I recommend reducing number of pins to the used ones only. If you wire 12 only, change BUTTONS to 12.
Look at this guide
Add USB Game Controller to Arduino Leonardo/Micro
Does anyone experience missed key presses? Not every press is recognized. I don't know if it's the hub's fault.
Edit:
I made a new sketch which doesn't use the slow digitalRead commands. I also reduced power consumption using the power reduction registers.
I recommend reducing number of pins to the used ones only. If you wire 12 only, change BUTTONS to 12.
Code: Select all
#include <Keyboard.h>
#define BUTTONS 16
int keycode_arr[] =
{
129, // PIN2 LEFT SHIFT
32, // PIN3 Space bar (Button 3)
130, // PIN4 LEFT-ALT (Button 2)
128, // PIN5 LEFT-CTRL (Button 1)
215, // PIN6 RIGHT
217, // PIN7 DOWN
216, // PIN8 LEFT
218, // PIN9 UP
122, // PIN10 Z
176, // PIN16 ENTER
108, // PIN14 (left shoulder - l)
114, // PIN15 (right shoulder - r)
112, // A0 PAUSE
177, // A1 ESC
205, // A2 F12
17 // A3 CTRL
};
int key_state[BUTTONS];
void setup()
{
PRR1 = PRR1 |
(
(1 << PRTIM2) |
(1 << PRTIM3) |
(1 << PRUSART1)
);
PRR0 = PRR0 |
(
(1 << PRTWI) |
(1 << PRSPI) |
(1 << PRTIM1) |
(1 << PRADC)
);
DDRB = DDRB & ~
(
(1 << DDB1) |
(1 << DDB2) |
(1 << DDB3) |
(1 << DDB4) |
(1 << DDB5) |
(1 << DDB6)
);
PORTB = PORTB |
(
(1 << PB1) |
(1 << PB2) |
(1 << PB3) |
(1 << PB4) |
(1 << PB5) |
(1 << PB6)
);
DDRC = DDRC & ~ (1 << DDC6);
PORTC = PORTC | (1 << PC6);
DDRD = DDRD & ~
(
(1 << DDD0) |
(1 << DDD1) |
(1 << DDD4) |
(1 << DDD7)
);
PORTD = PORTD |
(
(1 << PD0) |
(1 << PD1) |
(1 << PD4) |
(1 << PD7)
);
DDRE = DDRE & ~ (1 << DDE6);
PORTE = PORTE | (1 << PE6);
DDRF = DDRF & ~
(
(1 << DDF4) |
(1 << DDF5) |
(1 << DDF6) |
(1 << DDF7)
);
PORTF = PORTF |
(
(1 << PF4) |
(1 << PF5) |
(1 << PF6) |
(1 << PF7)
);
Keyboard.begin();
}
void loop()
{
int port_b;
int port_c;
int port_d;
int port_e;
int port_f;
port_b = PINB;
port_c = PINC;
port_d = PIND;
port_e = PINE;
port_f = PINF;
key_state[0] = ((port_d & (1 << PD1)) == 0); // PIN2
key_state[1] = ((port_d & (1 << PD0)) == 0); // PIN3
key_state[2] = ((port_d & (1 << PD4)) == 0); // PIN4
key_state[3] = ((port_c & (1 << PC6)) == 0); // PIN5
key_state[4] = ((port_d & (1 << PD7)) == 0); // PIN6
key_state[5] = ((port_e & (1 << PE6)) == 0); // PIN7
key_state[6] = ((port_b & (1 << PB4)) == 0); // PIN8
key_state[7] = ((port_b & (1 << PB5)) == 0); // PIN9
key_state[8] = ((port_b & (1 << PB6)) == 0); // PIN10
key_state[9] = ((port_b & (1 << PB2)) == 0); // PIN16
key_state[10] = ((port_b & (1 << PB3)) == 0); // PIN14
key_state[11] = ((port_b & (1 << PB1)) == 0); // PIN15
key_state[12] = ((port_f & (1 << PF7)) == 0); // A0
key_state[13] = ((port_f & (1 << PF6)) == 0); // A1
key_state[14] = ((port_f & (1 << PF5)) == 0); // A2
key_state[15] = ((port_f & (1 << PF4)) == 0); // A3
for (int i = 0; i < BUTTONS; i++)
{
if (key_state[i] == 1)
{
Keyboard.press(keycode_arr[i]);
}
else
{
Keyboard.release(keycode_arr[i]);
}
}
}
Re: Arduino Pro (Leonardo Micro)
Do I need to download a "Keyboard.h" library somewhere?
*EDIT: I just found out that the library is built-in the Arduino IDE.
*EDIT: I just found out that the library is built-in the Arduino IDE.
- winnetouch
- Posts: 158
- Joined: Mon Jul 11, 2016 10:56 am
- Has thanked: 2 times
- Been thanked: 30 times
Re: Arduino Pro (Leonardo Micro)
This is going to be a really noob question...myPiZero wrote:You can make a joystick with the analog inputs.
Look at this guide
Add USB Game Controller to Arduino Leonardo/Micro
Does anyone experience missed key presses? Not every press is recognized. I don't know if it's the hub's fault.
Edit:
I made a new sketch which doesn't use the slow digitalRead commands. I also reduced power consumption using the power reduction registers.
I recommend reducing number of pins to the used ones only. If you wire 12 only, change BUTTONS to 12.
Code: Select all
#include <Keyboard.h> #define BUTTONS 16 int keycode_arr[] = { 129, // PIN2 LEFT SHIFT 32, // PIN3 Space bar (Button 3) 130, // PIN4 LEFT-ALT (Button 2) 128, // PIN5 LEFT-CTRL (Button 1) 215, // PIN6 RIGHT 217, // PIN7 DOWN 216, // PIN8 LEFT 218, // PIN9 UP 122, // PIN10 Z 176, // PIN16 ENTER 108, // PIN14 (left shoulder - l) 114, // PIN15 (right shoulder - r) 112, // A0 PAUSE 177, // A1 ESC 205, // A2 F12 17 // A3 CTRL }; int key_state[BUTTONS]; void setup() { PRR1 = PRR1 | ( (1 << PRTIM2) | (1 << PRTIM3) | (1 << PRUSART1) ); PRR0 = PRR0 | ( (1 << PRTWI) | (1 << PRSPI) | (1 << PRTIM1) | (1 << PRADC) ); DDRB = DDRB & ~ ( (1 << DDB1) | (1 << DDB2) | (1 << DDB3) | (1 << DDB4) | (1 << DDB5) | (1 << DDB6) ); PORTB = PORTB | ( (1 << PB1) | (1 << PB2) | (1 << PB3) | (1 << PB4) | (1 << PB5) | (1 << PB6) ); DDRC = DDRC & ~ (1 << DDC6); PORTC = PORTC | (1 << PC6); DDRD = DDRD & ~ ( (1 << DDD0) | (1 << DDD1) | (1 << DDD4) | (1 << DDD7) ); PORTD = PORTD | ( (1 << PD0) | (1 << PD1) | (1 << PD4) | (1 << PD7) ); DDRE = DDRE & ~ (1 << DDE6); PORTE = PORTE | (1 << PE6); DDRF = DDRF & ~ ( (1 << DDF4) | (1 << DDF5) | (1 << DDF6) | (1 << DDF7) ); PORTF = PORTF | ( (1 << PF4) | (1 << PF5) | (1 << PF6) | (1 << PF7) ); Keyboard.begin(); } void loop() { int port_b; int port_c; int port_d; int port_e; int port_f; port_b = PINB; port_c = PINC; port_d = PIND; port_e = PINE; port_f = PINF; key_state[0] = ((port_d & (1 << PD1)) == 0); // PIN2 key_state[1] = ((port_d & (1 << PD0)) == 0); // PIN3 key_state[2] = ((port_d & (1 << PD4)) == 0); // PIN4 key_state[3] = ((port_c & (1 << PC6)) == 0); // PIN5 key_state[4] = ((port_d & (1 << PD7)) == 0); // PIN6 key_state[5] = ((port_e & (1 << PE6)) == 0); // PIN7 key_state[6] = ((port_b & (1 << PB4)) == 0); // PIN8 key_state[7] = ((port_b & (1 << PB5)) == 0); // PIN9 key_state[8] = ((port_b & (1 << PB6)) == 0); // PIN10 key_state[9] = ((port_b & (1 << PB2)) == 0); // PIN16 key_state[10] = ((port_b & (1 << PB3)) == 0); // PIN14 key_state[11] = ((port_b & (1 << PB1)) == 0); // PIN15 key_state[12] = ((port_f & (1 << PF7)) == 0); // A0 key_state[13] = ((port_f & (1 << PF6)) == 0); // A1 key_state[14] = ((port_f & (1 << PF5)) == 0); // A2 key_state[15] = ((port_f & (1 << PF4)) == 0); // A3 for (int i = 0; i < BUTTONS; i++) { if (key_state[i] == 1) { Keyboard.press(keycode_arr[i]); } else { Keyboard.release(keycode_arr[i]); } } }
How do I change a key function. Like if I want to change pin 2 to be a W for instance. How would I go about doing that?
Re: Arduino Pro (Leonardo Micro)
Replace it with the according value below.
Code: Select all
These are the ones (note they are hex, not decimal):
#define KEY_LEFT_CTRL 0x80
#define KEY_LEFT_SHIFT 0x81 //(this is decimal 129, but you could also use 0x81)
#define KEY_LEFT_ALT 0x82
#define KEY_LEFT_GUI 0x83
#define KEY_RIGHT_CTRL 0x84
#define KEY_RIGHT_SHIFT 0x85
#define KEY_RIGHT_ALT 0x86
#define KEY_RIGHT_GUI 0x87
#define KEY_UP_ARROW 0xDA
#define KEY_DOWN_ARROW 0xD9
#define KEY_LEFT_ARROW 0xD8
#define KEY_RIGHT_ARROW 0xD7
#define KEY_BACKSPACE 0xB2
#define KEY_TAB 0xB3
#define KEY_RETURN 0xB0
#define KEY_ESC 0xB1
#define KEY_INSERT 0xD1
#define KEY_DELETE 0xD4
#define KEY_PAGE_UP 0xD3
#define KEY_PAGE_DOWN 0xD6
#define KEY_HOME 0xD2
#define KEY_END 0xD5
#define KEY_CAPS_LOCK 0xC1
#define KEY_F1 0xC2
#define KEY_F2 0xC3
#define KEY_F3 0xC4
#define KEY_F4 0xC5
#define KEY_F5 0xC6
#define KEY_F6 0xC7
#define KEY_F7 0xC8
#define KEY_F8 0xC9
#define KEY_F9 0xCA
#define KEY_F10 0xCB
#define KEY_F11 0xCC
#define KEY_F12 0xCD
//and the keys (note that these are decimal.....sorry)
#define KEY_A 4
#define KEY_B 5
#define KEY_C 6
#define KEY_D 7
#define KEY_E 8
#define KEY_F 9
#define KEY_G 10
#define KEY_H 11
#define KEY_I 12
#define KEY_J 13
#define KEY_K 14
#define KEY_L 15
#define KEY_M 16
#define KEY_N 17
#define KEY_O 18
#define KEY_P 19
#define KEY_Q 20
#define KEY_R 21
#define KEY_S 22
#define KEY_T 23
#define KEY_U 24
#define KEY_V 25
#define KEY_W 26
#define KEY_X 27
#define KEY_Y 28
#define KEY_Z 29
#define KEY_1 30
#define KEY_2 31
#define KEY_3 32
#define KEY_4 33
#define KEY_5 34
#define KEY_6 35
#define KEY_7 36
#define KEY_8 37
#define KEY_9 38
#define KEY_0 39
Who is online
Users browsing this forum: Google [Bot] and 1 guest