This article explains how to sync a PS3 controller. Instructions apply to official PS3 controllers from Sony. Support for third-party controllers is mixed, particularly those that require a separate dongle.
PS3 How to sync your controller
To sync a PS3 controller to a PlayStation 3 console, you'll need a mini-USB cable. Sony recommends using the cable that came with your system. If you have trouble syncing with a third-party cable, try a different cable. Most third-party cables work fine, but there are some that don't.
Here's how to sync a PS3 controller with a PlayStation 3 console:
Turn on your PlayStation 3.