This is the source code for my Rail Pistol Remix.
The code is for an Arduino nano, but there's nothing platform specific. You can just as well use an ESP8266/ESP32/... anything that fits into the housing.
You can use a PlatformIO IDE to compile the project.