Help with arduino and raspberry project

Hi everyone,

I want to make an arcade machine using arduino leonard and raspberry (model B)… Today i got my arduino leonard and constructed a simple controller but when I connected arduino on the rasp, it’s performance got whorst and I wasn’t able to enjoy metal slug. Rasp recieved signals but I was playing for about 40 seconts and in the game had passed only 10 second (due to rasp’s low performance). I tried also a separate power plug for the arduino and an active usb hub but nothing. When I disconnected arduino from the rasp, it could easy process the game. Any idea? what else should i try? thanks in advance. Here is arduino code

char buttonOne = 2,
buttonTwo = 3,
buttonThree = 4,
buttonFour = 5,
potOne = A0,
potTwo = A1;

void setup()
pinMode (buttonOne, INPUT);
pinMode (buttonTwo, INPUT);
pinMode (buttonThree, INPUT);
pinMode (buttonFour, INPUT);
pinMode (potOne, INPUT);
pinMode (potTwo, INPUT);


void loop()
if (digitalRead(buttonOne)) Keyboard.print(‘a’);
if (digitalRead(buttonTwo)) Keyboard.print(‘b’);
if (digitalRead(buttonThree)) Keyboard.print(‘c’);
if (digitalRead(buttonFour)) Keyboard.print(‘d’);
if (analogRead(potOne)>=800) Keyboard.print(‘e’);
if (analogRead(potOne)<=200) Keyboard.print(‘f’);
if (analogRead(potTwo)>=800) Keyboard.print(‘g’);
if (analogRead(potTwo)<=200) Keyboard.print(‘h’);

an active usb hub

A USB hub will always be slower than not using one.

It looks like you are flooding the Pi with data. That loop is very crude and will send thousands of characters when ever a button is down. You need better code in the arduino, code that only sends information when the button makes a transition not when it is at a specific level.

Read the how to use the forum sticky and use proper code tabs when posting code.

Read this before posting a programming question

How to use this forum