Go to the home screen and go to the register a friend section of your 3DS touch screen. If your friend is nearby, you should be able to tap their Mii and 3DS friend code on the screen. If not, you can manually enter your friend's friend code.