Several years ago I got somewhat fed up reinventing the microcontroller wheel over and over again. I wasn't able to keep up with the speed new MCU types with their specialties, new possibilities and peripheral break out boards hit the market. Even in the more stable Arduino environment I wasn't really happy with the common low-level approach: Write a few functions, send serial debugging messages, throw in some library and write individual code for each new application.
So I decided to develop an object-oriented framework that would allow me to construct the software with classes from a kind of "part box" just like when experimenting with hardware.
This project more or less sat around month after month, done halfway because I did not really have enough time and motivation for this quite extensive undertaking. Plus I had to dive into C++ again which I hadn't touched for years. But then I accidentally rediscovered my passion for 0 gauge model trains, and I decided to modify some old locomotives (first a 1970s Lima model of a famous elegant French diesel engine - see photos) to run remote controlled on currentless garden tracks with any kind of custom functions imaginable, like sound modules and whatnot. I thought this might be a rather playful testing ground for the C++ framework.
And it worked. I regained motivation, so the framework does exist now, and I consider it useful and extensive enough to release it on Github. Please head over there for features, details and instructions of use.
The microcontroller remote control based on RFM69 boards works quite nice because I implemented a communication protocol that handles asynchronous messaging very well, thus allowing for the continuous execution of numerous other tasks. This remote control system is constant work in progress, though, and my pile of ideas for using it grows higher and higher, tempting me to tinker with new model hardware all the time. For instance, I found a nice old model yacht in the cellar I really liked as a child and fortunately never gave away. It had just one huge drawback: It didn't feature any kind of remote control at all. You had to manually adjust the rudder to let the yacht ride in circles and/or tie it to a string to prevent the loss of the boat.
So more than 40 years later I modified the old model boat from the 1970s with my homemade RFM69 remote control - and it works like a charm. The radio module's range apparently reaches way beyond my visual range (although I don't use LoRa/long range modules), and they nicely report back the signal strength.
Proof of concept done, I guess, with an admittedly crude grey prototype remote control box - the thumbsticks equipped with repurposed screw feet provide a smooth and safe handling, though. The small OLED screen in the middle of the box is intended to toggle between modes (trains, ships...) and to invoke tons of special functions, but I haven't implemented all that yet. I highly recommend using radio modules like RFM69 or Zigbee to build remote controls - that way they can be customized endlessly. In my opinion this is a much simpler and safer straightforward way than remote controlling via WiFi and the TCP/IP stack. I also prefer physical joysticks and buttons to a smartphone screen with virtual controls.
The diesel engine is equipped with a Feather M0 with RFM69. Since the original motor runs on 12V, I also threw in a 12V step-up voltage regulator. The motor is driven by an Adafruit TB6612 driver board, and the sounds will be played from one of the ubiquitous DFRobot MP3 boards.
The boat is controlled by a Feather M0/RFM69 as well. Since its (also still original) motor draws quite a lot of current and runs on approx. 4.5V, I use a 8838 motor driver board.
Don't forget to use anti-noise capacitors with old motors that might not be equipped with them already! If you omit the capacitors, the motor will interfere with the RFM69 signal.