Firing projectiles
Two cannons on top of the tank fire LEGO spheres. They are made of the special LEGO element that is specifically designed for this purpose. Both cannons are powered by the same EV3 medium motor, which is plugged into port A.
The motor splits its power to both cannons through a 90-degree gear connection. On either side there is a cam mechanism. When the motor spins, the cams slide a rod back and forth through the firing element. When the cam pushes the rod into the forward position, it ejects a sphere from the firing element at high velocity. This is how the turret fires the spheres. The motor continues to rotate the cam, and the rod slides back to make room for another sphere, which reloads the cannon. By simply setting the motor to spin continuously in one direction, each cannon can automatically fire a sphere, reload, then repeat the process:
The two cannons operate simultaneously, but their cams are staggered 180 degrees, which causes them to alternate their firing. This is done for two reasons: the first is that this allows the firing to be smoother because one cannon will reload while the other is firing. The second reason is to balance the load on the motor. The motor needs to apply force to fire a projectile, so opposing the cams evens out the load and makes it more manageable for the motor.
The gear ratio on the 90-degree connection is 1.67:1, meaning that it takes 1.67 turns of the motor to cycle the cams once. Aside from slowing the rotation, this increases the torque that the motor applies to the spheres and further decreases the load on the motor.
Here is the turret mechanism; the ammo silos have been removed to give us a clearer view: