Scaling PID Output

I have implemented a PID function using the formula,

correction = Kp * error + Kd * (error - prevError) + kI * (sum of errors)

What should I do to keep my output between a certain range? say 0-255 If I disregard any value not between 0 to 255 it produces a jiggly behavior?

How about:

if (correction > 255) {
   correction = 255;
} else if (correction < 0) {
   correction=0;
}

--
The Quick Shield: breakout all 28 pins to quick-connect terminals

that what I am doing right now but I get too many 0's or 255's so I was wondering if there is technique to better distribute my input range to my output range? or should I just play with the constants...

If you're getting mostly 0's and 255's you're building a bang-bang controller which suggests you have too much gain in the system. I would play with the constants...turn down Kp, set Kd=Ki=0 and just get some basic (non-saturating) control going. Then maybe turn up Ki a bit to deal with steady-state error, if it exists, and if you feel lucky turn up Kd to see if you can improve your tracking rate.

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons

Telling us something about the types of the variables involved, and showing the actual code that implements the formula would be useful.