I'm building a motorized train. The locomotive has two Powered Up train motors, one at each end. However, no matter where I place the hub inside the locomotive, the wires on the train motors are too short to both reach the hub.
So, I have decided to try to connect each motor to a separate hub. The problem is that the motors have to spin in the opposite direction. I know that if I put one motor on the "A" output of one hub and the other motor on the "B" output of the other hub, then I can control the motors independently, but I was wondering if there was a way to program the hubs so that I can control both motors together. Is this possible? If so, what would an example program look like to do this? I can also program in Python and Java if that helps at all. Below is a picture of my current setup.