From the Super Mario Wiki
Basketball is a Court & Field Sports Event that exclusively appears in the Nintendo 3DS version of Mario & Sonic at the London 2012 Olympic Games. The objective of this event is to score as many points as possible by shooting balls into the hoop.
To start this event, the player must firstly tilt their console away from them to cause their character to walk towards the hoop and grab their first ball. The player must then return their console to a vertical position to begin the event. The player is given a twenty second time limit to score as many points as possible by shooting different types of balls into the basket. Orange and white ones are worth one point, blue ones are worth two points and rainbow colored ones are worth three points. To shoot the balls, the player must aim the cursor shown onscreen so that it lines up with the rectangle on the hoop's backboard. The cursor will turn red if the player has lined the shot up well enough to be able to score, or will remain yellow if the shot will miss. Once the player has lined up their shot, they must gently thrust their system away from them to shoot the ball towards the hoop, and will score varying numbers of points depending on the type of ball thrown. Their character will catch the balls thrown at them automatically and can only shoot when holding one. The type of balls thrown at the character are random, although they always start off as being single point orange and white ones. A time limit will be displayed on screen when the player only has ten seconds left and will count down, with the cursor being removed during the final five seconds. Once the time is up, the player will not be able to throw any more balls, but any that were thrown prior to the time expiring that have yet to score or miss the hoop will be counted, before the player's final score is decided.
Hold the system vertically!