
Simulador Arduino
(Windows | Linux)
About
Simulador Arduino is a real-time simulation tool for electronic circuits and the Arduino Uno, designed specifically for teachers and students enrolled in an Arduino course offered by LabTIME. Developed using Unreal Engine 4, this simulator allows users to construct circuits from a set of available electronic components displayed on a tray. Users can write new sketches for the Arduino Uno using a built-in editor that compiles the code and integrates it with the game's code.
When users simulate the circuit, the simulator employs a third-party library called NGSpice to simulate electronic circuits. The results are captured and displayed as visual feedback. Concurrently, a separate thread executes the uploaded Arduino code, working in tandem with the NGSpice simulation to provide a comprehensive and interactive learning experience.
​
Simulador Arduino is designed for internal use only and is utilized exclusively during LabTIME's Arduino courses. Therefore, there is no public link available.
Project Info
-
Role: Gameplay Programmer
-
Team Size: 6
-
Time Frame: 1 yr 4 mos
-
Engine: Unreal Engine 4
-
Project Management: Trello
-
Version Control: Perforce Helix Core

Constructing a new circuit to simulate.

Simulating circuit with user arduino code.
My Role
Core Gameplay Systems
-
Integrated the NGSpice third-party library for Arduino circuit simulation.​
-
Developed a system to translate user-created Arduino scripts into C++ using Regex.
-
Integrated the g++ compiler to compile user-created Arduino scripts.
-
Compiled user-created scripts into shared libraries for linking with game's code.
-
-
Implemented a threading system to concurrently run translated Arduino scripts and NGSpice simulations.
-
Enabled real-time updating of circuit simulations.
-
-
Developed a system for saving and loading circuit data.
-
Created functionality for exporting and importing circuit data using JSON files.
-
Enabled manipulation and interaction with circuit elements, including creation, rotation, property changes, and removal.
-
Designed and implemented UI elements for enhanced user interaction.
-
Refined the game code architecture by utilizing Unreal Engine's modules.
Users-support
-
Provided player support for installation and game opening issues.
What I learned
In this project, I gained extensive experience in profiling and optimization, ensuring the game ran efficiently on low-end computers, including those used by teachers and in public schools. Integrating Unreal Engine with a real-time third-party library was a significant challenge, requiring the translation of game data into NGSpice's format to simulate circuits accurately.
​
One major issue was that NGSpice is not designed to accurately simulate the Arduino Uno, so we had to implement several workarounds to achieve more accurate simulations. However, these shortcuts could sometimes cause NGSpice to crash during simulations. To address this, we developed complex algorithms to detect problematic cases. For example, I created a graph-based algorithm to analyze constructed circuits before starting a simulation. If a circuit was identified as problematic, the simulation would be disabled, and an error message displayed. This approach was particularly effective because Unreal Engine's box collisions allowed each circuit point to be translated into a unique grid position, facilitating the construction of a graph that could store and run checking algorithms on the circuit.
​
Translating user-generated code into C++, linking shared libraries, and managing a threading system were also complex tasks. This involved developing a system to recognize compilation errors and provide user-friendly feedback, using a tokenized approach to process the written code. Additionally, the threading system required precise control to prevent race conditions during simulations.
​
This was also my first project utilizing Unreal Engine's modules, resulting in more flexible and maintainable code. This experience proved valuable for future projects. I collaborated closely with user support, gaining insights into considerations that should be addressed early in development.