You add friends by tapping on the orange smiley face in your 3ds's Home screen, then from there you swap your 16 digit code with a friends via local wireless or internet. Once both people have added each other (you will know when it happens), you will be able to battle, trade, etc.
Next time you have a question use the In-Game Quick Questions & Answers thread :) good luck