3
votes

I'm super new to coding and I just started using the Godot game engine. I'm trying to get a body in Godot to receive numeric input serially from an Arduino. I know how to do this in C++ as well as python, but have never used a game engine before. Does anyone have any recommendations?

Since I knew how to receive input in python, I tried installing python through Godot's AssetLibrary, but documentation seems to be pretty scarce, so I'm not entirely sure how to run it on Godot. If anyone knows how to integrate python into Gdscript (i.e. have Gdscript call python to read the Arduino output) that would be fantastic, but if anyone has a general simple way of receiving serial input, that would also be great.

Thanks!!

1

1 Answers

0
votes

I'm still a bit new to this myself. I think there are a few ways to accomplish this. Do you require exact numbers or are we talking ballpark numbers?

If you use the C# version of Godot you could probably use System.IO.Ports.SerialPort to get input from your Arduino via serial port but I have not actually tested this myself yet. I will update this answer if I get around to it.

Optionally if serial communication isn't strictly necessary you could use an Arduino Leonardo or compatible with ATmega32u4. This would allow you to send input over USB as if the Arduino was a keyboard, mouse or joystick/gamepad.

Then you can use standard GDScript functionality to decode the incoming data. You can for example decide that the F-keys are your digits (F1=1, F2=2 ... F10=0) and F11 is the signal that the number is complete. Hope this helps.