Hat Switch in DIY Arduino Mega Button Box?

Hello fellow sim racers!

I plan to build my own button box soon using this writeup which is built around an arduino mega. This will be my first journey into the world of arduinos but I’m quite capable and have confidence I can get everything working given enough hours and fragmented tutorials.

I’m thinking about adding at least one, maybe two, hat switches in order to navigate menus and/or black boxes. My basic question is whether or not anyone has gotten a hat switch working with an arduino mega? Is there any limitation of the mega that just doesn’t work with hat switches?

Just want to know before I order some from china today and find out it doesn’t work a month and a half from now when it gets to me.

Thanks for any help!!
 
It is possible with some work.
However an easier option may be an STM32 bluepill board and freejoy. This is what I'm using in projects now instead of arduinos. Hat switches are super easy.
 
It is possible with some work.
However an easier option may be an STM32 bluepill board and freejoy. This is what I'm using in projects now instead of arduinos. Hat switches are super easy.
Agree. Been using Arduinos before. Now only use STM32 with Freejoy. No need to code, and easy to build. (so far I'm using in DIY Pedals and DIY Button box)

STM32F103C8T6

This is what you should look for, if you are interest. Is more expensive, but in the end, much better.
 
Last edited:
Fot the Hat stick. What I'm using is this:
1650961762672.png

You can find this joystick really cheap and everywhere. Using Freejoy, you can convert Axis to Button. So, X and Y will be devided in 3 sections each. Once the Joystick is around a define region will act like a button. So, you can have a cursor function with a analog joystick.
Together with Autohotkey, you can convert Joy button press to keyboard press, if needed
 
Last edited:
It's also the only easy option to use an alps 7 way "funky switch" without custom code because of the center push.

I use these as a neat (but pricey) solution.
This Funky switch is amazing. Is the same used by Fanatec wheels.

In my opinion, for a Button box, where you have allot of space, you can use other cheap alternatives. For a DIY wheel, this funky switch is a must!!!
 
Fot the Hat stick. What I'm using is this:
View attachment 561990

You can find this joystick really cheap and everywhere. Using Freejoy, you can convert Axis to Button. So, X and Y will be devided in 3 sections each. Once the Joystick is around a define region will act like a button. So, you can have a cursor function with a analog joystick.
Together with Autohotkey, you can convert Joy button press to keyboard press, if needed
I actually just ordered 5 of these from AliExpress because they were dirt cheap and I figured I’d find a way to use them. So I’d be able to use these most effectively with a Bluepill board? I already ordered 2 Pro Micros and a Mega so I could follow other folks’ button box/wheel writeups. Would I be able to use this bluepill board in conjunction with a pro micro or mega? Or does it need a different board to actually connect to the computer?

Thanks for all this help @Jallisey and @Bitacaia. I’m pretty capable once I have my hands on hardware and can play with it but up until then, I am pretty useless! Haha. I just have a lot to learn since I haven’t used arduinos quite yet!
 
First, Blue Pill has been cloned to death; unlikely to get one with STM chip
Second, Blue Pill is weak for native USB, and STM's Arduino library does not support HID for it.
Better to use Black Pill.
They seem to be similarly priced on AliExpress so blackpill is fine with me! These boards are not standalone, correct? They still need to be connected to an arduino?
 
They still need to be connected to an arduino?
Not at all; they replace Arduino, and can be programmed using
the Arduino IDE, after configuring appropriate board support.
Many Arduino sketches run with only pin assignments changed.
For Black Pills to do USB HID, it is easier to use the older
“Arduino STM32” board support by Roger Clark, rather than STM's,
with USBComposite_stm32f1 by arpruss.

Here is one working example:
https://blog.yavilevich.com/2020/06...s-as-generic-macros-for-an-android-head-unit/

Some genuine Arduinos can also do USB HID:
https://www.arduino.cc/en/Reference/HID
 
First, Blue Pill has been cloned to death; unlikely to get one with STM chip
Second, Blue Pill is weak for native USB, and STM's Arduino library does not support HID for it.
Better to use Black Pill.
Bluepill is the STM32F103 and blackpill is STM32F411. if I see it correctly.

Just one more tip:
I recently bought more blue pills, and I made a mistake because I wasn't aware of the differences, I got the STM32F103C6T6 and not the correct one STM32F103C8T6. So, the Freejoy software doesn't work on the C6... but luckly this sofware works (OpenSimHardware) for this version.

I will buy some black pills and see how they work. Thanks for the tip
 
Last edited:

What are you racing on?

  • Racing rig

    Votes: 528 35.2%
  • Motion rig

    Votes: 43 2.9%
  • Pull-out-rig

    Votes: 54 3.6%
  • Wheel stand

    Votes: 191 12.7%
  • My desktop

    Votes: 618 41.2%
  • Something else

    Votes: 66 4.4%
Back
Top