The Cannon is one of the only placeable hardmode weapons in the game. Once placed on a solid surface of at least 2 blocks horizontally the cannon can be used to fire Cannonballs, which do over 300 damage. To fire the Cannonball from a Cannon the player must be holding a Cannonball in their hand and then left click on the Cannon. This will consume a Cannonball and fire out of the front of the Cannon. Holding the left click will auto-fire the cannon, with rapid succession. The Cannonball that is fired is heavily affected by gravity and will explode on impact with any mob, player, or surface. The Cannonball will also pass through a number of enemies, similar to the Unholy Arrow. It is a definitely efficient weapon to use against the Destroyer, being able to kill it in as little as 30 seconds. Cannons can be activated through switches, but the fired shots will not deal damage.
When placed, the cannon will initially point at a 90 degree angle (straight right). By right-clicking the left side of the cannon, players can adjust the angle by 22.5 degrees counter-clockwise per right-click. This will affect the trajectory of the cannon ball. This can be repeated until the cannon faces a 270 degree angle, (straight left). Right-clicking the right side of the cannon will rotate the cannon clockwise by the same amount. However the cannon cannot be aimed downward (91 to 269 degree angles).
For the velocity and damage output, it can be useful for pirate/goblin invasions. The best strategy for this would be to make room for two cannons at the ground level of your base, point them each in opposite directions, and buy about 150 cannon balls. This method is expensive, but it's good for quickly clearing out invasions.