I have a big project ahead of me and a lot of uncertainties. I want to make some sort of aircraft/spaceship simulator in Unreal Engine, with controls extending into the physical world.
Unreal Engine has a plugin called “Serial COM”, which I can use to communicate with my Arduino’s serial ports.
In my project I want to utilize:
Arduino UNO
around 50 Buttons
around 20 potentiometers/rotary encoders
up to 30 servos
Adafruit NFC breakout Board
Lots of Neopixel LEDs
Basically, I want to be able to control ALL these components through the computer, whether it be detecting a button/switch activation, changing a servo’s position, or individually controlling a bunch of addressable LEDs.
How do I make it so my Arduino can handle all of these components and send and receive simple data from and to the computer? Should I even be using an Arduino for this? Is there something more suitable for my project?
Any help or thought is greatly appreciated as I’m not even sure if this idea could work well with Arduino.
Next to none, this is more of a side hobby for me than anything. I've used Arduino with some LED's and small components before, but nothing too large or complicated.
Start small and scale up. That's a lot of IO's, a Mega2560 has 70, you'll need more than that. But if you start with just a few and scale up, then you'll have better success, esp considering where you're starting from.
One thing to address is permanent wiring. The bread boards are great for single item test, but for permanent projects, not so much.
Here is my solution to permanent & maintainable wiring.
Alright, thanks! Is there any hardware I can buy to get more IO's? or any way to chain more than one component, like a button or switch, to one output and still send different data from each one?
No, I have yet to buy any parts. I'm just wondering if something of this scale is possible, or even ideal to do with Arduino, or if I'm better off using some other method of connecting components like these to a game engine.
Many ways to have many outputs/inputs:
Buy a board with many inputs/outputs
I/O expander
Multiplexing
Charlyplexing
Scanning like in keyboards
Shift registers
Sharing pins
Chaining of addressable leds
All with their pros and cons. So do some googling...
Easy! An 8-bit output shift register and an 8-bit input shift register will get you a 64 button matrix with 5 pins (clock, data in, data out, latch1, latch2). You can use the SPI interface to do simultaneous input and output and only use one latch pin.
Easy! Two 16-way multiplexers on two analog input pins (32 inputs) or three 8-way multiplexers on three analog input pins (24 inputs). The multiplexers can share address pins so 6 pins either way.
Easy! Two of the Adafruit 16-pin PWM boards (about $16 each). I think they use I2C (pins A4 and A5).
I2C? SPI? Either way those buses can be shared.
Addressable LEDs only require 1 pin.
So that's:
SPI (3 pins) + latch (1 pin)
4 digital + 2 analog or 3 digital + 3 analog
I2C
I2C (or SPI with 1 more latch)
LEDS (1 pin)
So about 10 digital pins and 4 or 5 of the 6 analog pins (I2C uses 2). Well within the capability of the Arduino UNO.
Yeah right. You forgot that d0/d1 are comms and d13 is the internal LED. And all the code to run it will fit in an Uno too. That's a lot of muxes and support circuitry for a hobby project. OP: Get the components suggested and try to build each piece separately. Key matrixes only respond cleanly to one key at a time, multiple press scanning needs a different approach. Muxing pots will be slow to scan as analog settling time is needed.
So that's:
SPI (Pins 11, 12, and 13) + latch (Pin 10)
4 digital (Pins 9, 8, 7 and 6) + 2 analog (A0, A1) or
3 digital (Pins 9, 8 and 7) + 3 analog (A0, A1, A2)
I2C (Pins A4, A5)
I2C (or SPI with 1 more latch, Pin 5)
LEDS (1 pin, Pin 4)
Serial I/O (Pins 0 and 1 or use Leonardo in place of UNO)
That leaves A3 (or A2 and A3) for analog inputs and Pins 2 and 3. Further expansion can be done with I2C or SPI.
At over 9000 analog reads per second, I don't think 24 or 32 analog inputs will be too slow to be usable.
Have one diode per button for N-key roll-over.
Note: If you can use a Leonardo instead of the UNO you will probably get faster communication AND will free up Pins 0 and 1 for digital I/O (or a Serial peripheral). Also, it would allow the "button-box" to appear as a USB game controller or keyboard instead of a serial stream.
For a beginner for this task I would use something faster with more memory. Raspberry Pi Pico maybe?
Neopixels needs a lot of uninterrupted processor time. Rotary encoders need fast interrupts to make sure no step is missed. It will be tricky on a humble Arduino Uno.
That's why given a requirement for "around 20 potentiometers / rotary encoders" I would go with potentiometers. If encoders are preferable, an Arudino MEGA should have enough spare Pin Change interrupts to support 20 encoders.
Would another microcontroller like an Arduino MEGA or Due work better? I'm definitely open to using a more powerful option if that's what's required (especially with limited IO's on the Uno)
A Raspberry Pi would be ideal, and would work with most (if not all) of the components I want to include in the end, but I'm not sure how it would interface with Unreal Engine.
If anyone knows how I send signal to and from a Raspberry Pi to a game engine like this that would be very helpful. I can't seem to find any resources online of anyone trying something similar.
This "USB game controller" idea is on the right track of what I need to interface with a game engine, but I also need to send data back to the microcontroller from Unreal Engine/a game engine.
Is there any capability, physically or code-wise, that i can turn something like an Arduino Due/Mega or Raspberry Pi into such USB game controller and have it send data back and forth to and from the computer? I'm not totally bent on using just an Uno at this point considering physical limitations.
Once I know for certain that whatever microcontroller I have can properly interface with Unreal Engine then I'll start small with just a few components and build my way up from there, and I don't imagine I'll be spending more than two years on it.