Adding friend codes on your DS depends a little on the game you are playing. In many titles, you head downstairs at the Pokemon Center, receive your Pal Pad, and then register a name and code.
In Animal Crossing, the process is a bit different. Go to the gatehouse and click on the guards, then ask for your "friend code." Once they confirm you are connected to Wi-Fi, they will give you your code. To add someone to your friend roster, press the X button, click on the heart, then select Register, where you can enter their friend code.
Once you have it sorted, you are ready to connect and play with friends!