starting with the following function:
f(x)= -1     x < 0 
    = 0      x = 0
    = 1      x > 0 
notice that f(x) is odd and as such, it's fourier series expansion will only have sin() coeficients:
f(x)= Σ an * sin(2*n*Pi*x/L)

  an - fourier series coeficients yet to be determined
  L - length of the interval

an (the fourier series coeficients) are calculated as:

an=2/L * integral(a, a+L, f(x)*sin(2*n*pi*x/L), x)

if we calculate the expansion from a=-1 to a+L=1 we get (L=2):

an=2/2*integral(-1,1,f(x)*sin(2*n*pi*x), x)

noticing that f(x) and sin() are odd functions, their product will be even, and as such we can say that

integral(-1,1, ..., x)=2*integral(0,1, ..., x)


an =2*integral(-1,1,f(x)*sin(2*n*pi*x), x)
   = 2/(n*pi) * (1-(-1)^n)
   = 0           n even
     4/(n*pi)    n odd

f(x) then becomes:
f(x) = Σ 2/(n*pi) * (1-(-1)^n) * sin(2*n*Pi*x/2)
changing variables n=2k+1 (getting rid of the even terms (which are 0)):
f(x) = Σ 4/((2k+1)*pi) * sin((2k+1)*Pi*x)
if we get the value of f(x)at x=1/2 (which we know to be 1):
1 = Σ 4/((2k+1)*pi) * sin(k*pi+Pi/2)

  = Σ 4/((2k+1)*pi) * (-1)^k
divide by 4/pi:
pi/4 = Σ (-1)^k/(2k+1)

     = 1 - 1/3 + 1/5 - 1/7 + ....
just thought it'd be interesting to know how to actually get the result.

note though that this converges very slowly. Check the pi metanode for faster ways of calculating pi.