Open the GarageBand application by double-clicking on the icon in the Applications folder.
Select the guitar icon in the "New Project" window.
Create a new file by selecting "Create" when the dialog box appears. If you know the time signature of your piece, enter that in the time signature box.
Press the round "Record" button at the bottom of the screen and start playing into the microphone. The record button looks like a circle with a red dot in the middle. When you are done playing, press the "Record" button again, then press the "Play" button to stop the cursor from moving.