- Home /
Stand Alone App To Operate USB Controlled Relays
Is it possible for a stand alone Unity app to run actual physical devices via a USB controlled relay board? If so are there any tutorials, special plugins that may be needed? Any help on this greatly appreciated.
I've controlled servos and motors from Unity via USB connection to an Arduino, which was relatively trivial to set up.
I haven't used the Arduino.. I believe it is some "generic / all purpose" microcontroller board.. And from what you say, i gather it has a USB peripheral built in. (Does it also have a host / OTG?). If so, I would expect them to provide some driver also, for windows. Right? Then that would make things simple. Just that.. I have never tried (I don't even know what it takes) to call external "windows" device drivers in Unity..
And, on simil;ar search, I found this.. https://www.youtube.com/watch?v=E$$anonymous$$AWe2d7lC0
Where we control the LED (Or relay in your case) via Serial Port / UART.
Unless you are too particular about using USB, I suggest UART. Off my head i can think of the 8051 microcontroller that could do the job. No separate device drivers.. (and the microcontroller would come to less than 4-5 US$. It used to be equivalent of $1 in india, and then add to it a crystal and a few relays, and a power supply..). And teh best part is, you don't need a separate device driver.. Unity's C# shoudl have all you need. (Again, look at the video..)
As long as you can send and receive data from Unity, you can set up a separate/external program to handle the USB Stream.
Yeah if you have a commercially viable idea... don't go spilling it all over the internet.
Answer by TSRajesh · Dec 15, 2014 at 06:03 AM
USB driver is a whole new beast. I am not sure how much of experience you have with the USB protocol / drivers.., or with embedded systems as a whole. Unless it is of the standard classes (Mass-Storage class etc..) you will find that you may want to write a special USB driver. Hooking it up with Unity is again an entirely different effort.. I am not sure what that takes. Maybe you'll have better luck with a simpler standardized interface.. something like the UART (Serial Port).
I seemed to recall that someone somewhere else had asked about this too but I can't recall where but from what I remember about the post it certainly seemed possible.
Of course.. it is possible. In fact, I have done this.. a usb to parallel output, (can use to control relays) with a custom class implementation.. The Software (PC side) as well as Firmware (microcontroller with the USB peripheral controller on it) in my previous job. VC++ on the PC side.. I am not sure about integrating it into Unity though. Question.. Are you able to do it Outside of unity? If so, then you only have to worry about calling that driver from unity.. (Unity doesn't have any framework for writing device drivers). If not, it is not a trivial process..
Thanks, nope I have had no experience with this sort of thing myself, I do know people who are good at that type of stuff though. I just think it would be a cool idea if I could make an interactive interface for my 2 TV monitors on my $$anonymous$$night Rider 2 TV dash and actually have them turn devices on inside of the car. I already wired my switch pods unit to activate external speakers for $$anonymous$$.I.T.T.s Voice Projection unit part of which was wired into the upper console. I started creating my interface in Unity 3D because I had heard that Unity could do this.
Your answer
![](https://koobas.hobune.stream/wayback/20220613174046im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
how to view 3d model fully controllable in unity 5 0 Answers
Portrait Android app? 1 Answer
mobile app crash 0 Answers