# How to make a controller

**URL:** <https://forum.arduino.cc/t/how-to-make-a-controller/1411296>\
**Category:** General Guidance\
**Created:** [October 30, 2025, 5:32pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296 "2025-10-30T17:32:55Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![tdizzle76](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tdizzle76/32/1243317_2.png) [@tdizzle76](https://forum.arduino.cc/u/tdizzle76)\
**Post date:** [October 30, 2025, 5:32pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/1 "2025-10-30T17:32:55Z")

</div>

I am an absolute beginner, never coded before, but I have worked with hardware a lot. I have an arduino Leonardo R3 and 14 digital buttons, 2 analog joysticks, I would like to make a USB controller that can be plug and play. I am fine with having to configure the controller, I just need it to recognize that it is a controller.  
I really need help, because I've been trying to do this for 3 months, (even though I was told it would be simple) and I have not made any progress at all, so I obviously don't have the skills to code.

---

<div class="post-metadata">

**Author:** ![tdizzle76](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tdizzle76/32/1243317_2.png) [@tdizzle76](https://forum.arduino.cc/u/tdizzle76)\
**Post date:** [October 30, 2025, 5:37pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/2 "2025-10-30T17:37:41Z")

</div>

I also forgot to mention in this post but not all 14 buttons are necessary. I only need around 12 of them.

---

<div class="post-metadata">

**Author:** ![camsysca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/camsysca/32/1015228_2.png) [@camsysca](https://forum.arduino.cc/u/camsysca)\
**Post date:** [October 30, 2025, 5:50pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/3 "2025-10-30T17:50:50Z")

</div>

> [@tdizzle76](#):
>
> made any progress at all, so I obviously don't ha

1. divide and conquer, don't try to do it all.

2. Show us your code. We won't write it for you, but can guide you back onto the road when you ditch it.

3. Show us how it's wired - schematic, please, fritzing is poor communication

4. show us a photo of your assembled circuit - much can be told by visual inspection

---

<div class="post-metadata">

**Author:** ![camsysca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/camsysca/32/1015228_2.png) [@camsysca](https://forum.arduino.cc/u/camsysca)\
**Post date:** [October 30, 2025, 5:53pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/4 "2025-10-30T17:53:50Z")

</div>

to make your post, you obviously entered the Leonardo Category. Pity you didn't notice this:

> [@How to get the best out of this forum](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/1335460):
>
> Welcome to the Arduino forum! A guide explaining how to get the best out of this forum is available at the link below. Please read it:

---

<div class="post-metadata">

**Author:** ![camsysca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/camsysca/32/1015228_2.png) [@camsysca](https://forum.arduino.cc/u/camsysca)\
**Post date:** [October 30, 2025, 6:02pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/7 "2025-10-30T18:02:55Z")

</div>

I see this topic was moved to General Guidance.

Do you in fact have a Leonardo, or an Uno?

---

<div class="post-metadata">

**Author:** ![tdizzle76](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tdizzle76/32/1243317_2.png) [@tdizzle76](https://forum.arduino.cc/u/tdizzle76)\
**Post date:** [October 30, 2025, 6:08pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/8 "2025-10-30T18:08:59Z")

</div>

I didn't move anything, but I'll post some of the code in a while. At around 3:00PM

---

<div class="post-metadata">

**Author:** ![camsysca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/camsysca/32/1015228_2.png) [@camsysca](https://forum.arduino.cc/u/camsysca)\
**Post date:** [October 30, 2025, 6:12pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/9 "2025-10-30T18:12:18Z")

</div>

likely a moderator, though that usually only happens when it's obvious that the post is in the wrong place. In this case, you referenced Leonardo, so I presumed Leonardo. We'll see what you have to say at 3; no idea when that is, this is a global forum, but hey, we'll see.

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [October 30, 2025, 7:23pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/10 "2025-10-30T19:23:04Z")

</div>

The board specific categories are intended for problems with the specific board and not so much for projects that involve the board. That is (more than likely) why it was moved.

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [October 30, 2025, 7:32pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/11 "2025-10-30T19:32:47Z")

</div>

As a self-declared "absolute beginner" you have chosen a very challenging project.

A good first step in your journey would be to methodically go through one of the code examples for creating an HID mouse from the Leonardo, and make sure that you understand every line of it. [One such example, randomly chosen.](https://www.luisllamas.es/en/emulate-keyboard-mouse-arduino/)

---

<div class="post-metadata">

**Author:** ![tdizzle76](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tdizzle76/32/1243317_2.png) [@tdizzle76](https://forum.arduino.cc/u/tdizzle76)\
**Post date:** [October 30, 2025, 9:21pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/12 "2025-10-30T21:21:39Z")

</div>

Oh, also if it wasn't already obvious, this is my first time posting on the Arduino forum

---

<div class="post-metadata">

**Author:** ![tdizzle76](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tdizzle76/32/1243317_2.png) [@tdizzle76](https://forum.arduino.cc/u/tdizzle76)\
**Post date:** [October 30, 2025, 9:34pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/13 "2025-10-30T21:34:41Z")

</div>

It's a bit early, but here's the code: (Though I don't think any of it actually properly works.)

```arduino
void setup() {
// put your setup code here, to run once:
//Define pins for buttons
const int buttonPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; // Example pins for 10 buttons
const int numButtons = 10;

// Initialize serial communication
Serial.begin(9600);

// Set button pins as input with pull-up resistors
for (int i = 0; i < numButtons; i++) {
pinMode(buttonPins[i], INPUT_PULLUP);
}
}

void loop() {
// put your main code here, to run repeatedly:

// Define pins for joystick axes

const int joyX1 = A1; // Analog pin for joystick 1 X-axis
const int joyY1 = A2; // Analog pin for joystick 1 Y-axis
const int joyX2 = A3; // Analog pin for joystick 2 X-axis
const int joyY2 = A4; // Analog pin for joystick 2 Y-axis

int joyX1pin = 0;
int joyY1pin = 0;
int joyX2pin = 0;
int joyY2pin = 0;

// Read joystick values
joyX1pin = analogRead(joyX1);
joyY1pin = analogRead(joyY1);
joyX2pin = analogRead(joyX2);
joyY2pin = analogRead(joyY2);

//Define pins for buttons
const int buttonPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; // Example pins for 10 buttons
const int numButtons = 10;

// Read button states
String buttonStates = "";
for (int i = 0; i < numButtons; i++)
// DigitalRead returns LOW when button is pressed due to pull-up
if (digitalRead(buttonPins[i]) == LOW)
buttonStates = "1"; // Button pressed
else {
buttonStates = "0"; // Button not pressed
}

// Send data to Raspberry Pi in a structured format (e.g., CSV-like)
Serial.println(joyX1pin);
Serial.println(",");
Serial.println(joyY1pin);
Serial.println(",");
Serial.println(joyX2pin);
Serial.println(",");
Serial.println(joyY2pin);
Serial.println(",");
Serial.println(buttonStates); // Newline character to delimit messages
// Get rid of "ln" after testing on computer (I think)

delay(10); // Small delay to prevent overwhelming the serial buffer

}

```

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [October 30, 2025, 9:45pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/14 "2025-10-30T21:45:56Z")

</div>

> [@tdizzle76](#):
>
> any of it actually properly works.

Please explain what is "properly works" for you relating to the code?

---

<div class="post-metadata">

**Author:** ![tdizzle76](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tdizzle76/32/1243317_2.png) [@tdizzle76](https://forum.arduino.cc/u/tdizzle76)\
**Post date:** [October 30, 2025, 10:09pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/15 "2025-10-30T22:09:40Z")

</div>

The code needs to take the input from the 11 buttons (I forgot to add the 12th) and 2 control sticks, make the control sticks analog signal into a digital signal, and then send the digital signals to the Raspberry Pi (which will be expecting normal USB HID game controller inputs. It also easily lets you configure the buttons and joysticks, so as long as it thinks it's a HID controller it should work).

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [October 30, 2025, 10:37pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/16 "2025-10-30T22:37:37Z")

</div>

The code doesn't even begin to resemble an HID controller, but with some fixes, it could send button and joystick values to an RPi via a USB serial port connection.

---

<div class="post-metadata">

**Author:** ![tdizzle76](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tdizzle76/32/1243317_2.png) [@tdizzle76](https://forum.arduino.cc/u/tdizzle76)\
**Post date:** [October 30, 2025, 10:49pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/17 "2025-10-30T22:49:51Z")

</div>

Wait really? I thought this code was complete garbage, and I'd have to start over...

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [October 30, 2025, 10:51pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/18 "2025-10-30T22:51:59Z")

</div>

This part reads and reports only the status of the last button read (assuming that the wiring is correct).

```arduino
for (int i = 0; i < numButtons; i++)
// DigitalRead returns LOW when button is pressed due to pull-up
if (digitalRead(buttonPins[i]) == LOW)
buttonStates = "1"; // Button pressed
else {
buttonStates = "0"; // Button not pressed
}

```

Why not actually test code before posting it?

---

<div class="post-metadata">

**Author:** ![tdizzle76](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tdizzle76/32/1243317_2.png) [@tdizzle76](https://forum.arduino.cc/u/tdizzle76)\
**Post date:** [October 30, 2025, 11:01pm UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/19 "2025-10-30T23:01:10Z")

</div>

I did test the code, but I was paying too much attention to If the sticks were working, to realize that the buttons weren't. So I'll try to find a fix to that first.

---

<div class="post-metadata">

**Author:** ![tdizzle76](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tdizzle76/32/1243317_2.png) [@tdizzle76](https://forum.arduino.cc/u/tdizzle76)\
**Post date:** [October 31, 2025, 1:38am UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/20 "2025-10-31T01:38:23Z")

</div>

Nevermind, I'm really, really sorry for wasting your guys's time. I managed to find a tutorial while looking at ways to fix the button issue...

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [April 29, 2026, 1:39am UTC](https://forum.arduino.cc/t/how-to-make-a-controller/1411296/21 "2026-04-29T01:39:03Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
