Why do some pins have `~` signs next to their numbers?
Relax. Don't worry. These pins are called PWM and are the same as the other pins, except they have an &quot;added bonus.&quot;

Some uses from Arduino's Website:


Dimming an LED
Simulates an analog output.  The output is still digitally toggling from 0V to 5V.  However, low-pass filter (capacitor and resistor) to simulate analog voltages.
Generating audio signals.
Providing variable speed control for motors.
Generating a modulated signal, for example to drive an infrared LED    for a remote control.



How it works:
The PWM pins are controlled by on-chip timers which toggle the pins automatically at a rate of about 490Hz.  The &quot;Pulse Width Modulation&quot; (PWM) is how long the pin stays on or off for a single cycle of that frequency.  This can dim a LED by giving the illusion it is at half the brightness as before, where it is really flashing very quickly.

When there is a 25% duty cycle, it is on one-forth of the time.  If you used for a LED, it would appear about 1/4th as bright [give or take]. (Note: as some people pointed out this isn't truly proportional but let's leave it this way for simplicity. EX: 25% isn't always 1/4th the brightness.)
(If you are really electrical savvy, you could probably add a capacitor to make it also an analog output.)

How to use these pins to output:
First, you need to define the pin as output. Then, you use
analogWrite(ledPin, 128);
to start it. The ledPin is the PWM pin that you want to start PWM and 128 should be replaced with a number between 0 and 255; 0: 0% duty cycle (turns the pin completely off) and 255: 100% duty cycle. (turns the pin on completely)
Source: http://www.arduino-tutorials.com/arduino-pwm/

Why can't I just turn the light on and off really fast in my code?:
Technically, you can, however, there are some problems:

It may not be as precise as using the hardwired circuits with the Arduino
Its simpler just to type instruction instead of having lots of &quot;if&quot; statements

It's not really going to make that much of a difference if the Arduino's sole purpose is to generate PWM signals. However, if you put any delays longer than 50 MS in the main loop, it will mess up the timing. With the software approach you would want to eliminate any &quot;delay&quot; functions since the Arduino only runs on one thread (it can only do one thing at one time). If you know what you're doing, it won't make that much of a difference dimming the light, but if you have an extra pin with PWM, you're just wasting your time with a software approach.

As others have pointed out:
You still need a resistor for your circuits to limit current and voltage. You cannot skip this.