user3840: In the example of the arduino starter kit the point is to use a potenciometer to control a servo.
The code is 
angle = map(potVal, 0, 1023, 0, 179);

The output in the serial
potVal: 1023, angle: 179
potVal: 1015, angle: 177
potVal: 1023, angle: 179
potVal: 1016, angle: 177
potVal: 1023, angle: 179
potVal: 1023, angle: 179

I noticed that the servo is shaking like trying to go passing over the 179, when it is suppose to use an angle max 180º (0-179)
What could be the problem?

user3981: Since the previous answers were all code-related, let me suggest you use a smoothing capacitor. In noisy environments, or where you want to get more consistent readings, place a capacitor across your signal lines (signal to ground). The result is less "spikes" in your readings, and can sometimes cause a slight delay in signal changes, as charge has to build up in the capacitor before the voltage goes up.
http://www.learningaboutelectronics.com/Articles/What-is-a-smoothing-capacitor

user220: I like this method the best (personal preference) for smoothing signals:
//In setup
int bufferedVal = analogRead(A0);
int unbufferedVal = analogRead(A0);
#define _TOLERANCE_ 5

//The loop
unbufferedVal = analogRead(A0);
if(abs(unbufferedVal - bufferedVal) >= _TOLERANCE_ ) {
  bufferedVal = unbufferedVal;
}

This finds the error using the abs() function (absolute value; makes sure it is positive).
Another thing you can do is round it to the tenth placeholder (i.e. 88 -> 90, 83 -> 80) so it always is a good number to work with:
int val = analogRead(A0);
val += 5;
val = val / 10;
val = val * 10;

The last two lines work because of the lack of precision that integers offer with decimals. If I divide 88 by 10, it doesn't output 8.8; it outputs 8 instead. We then multiply by ten again so it isn't 8 when it really should be 80. The only problem with this is it only rounds down. We can fix this by adding 5 (the halfway point between 10 and 0). That way, it goes: 88 to 93 to 9.3 to 9 to 90.
NOTE: I'm not sure if the compiler will notice the redundancy of the last two lines. If it acts weird, try using the volatile keyword.

user3917: If the problem is due to jittery pot readings, you may want to smooth the potval data sequence by code like the following, where rawreading stands for what you just read from the potentiometer's input line.
potval = alpha*potval + (1-alpha)*rawreading;

Set alpha to a number (eg 0.8 or 0.9 or 0.95 etc) between 0 and 1.  alpha represents the fraction of the old value that you retain, and  1-alpha represents the fractional influence of the new raw reading.   alpha closer to 1 causes smoother but slower response.
If you prefer integer arithmetic for faster or smaller code, then represent alpha as a ratio of integers.  For example:
potval = (potval*12 + rawreading)/13;

The technique mentioned above is called exponential smoothing or  exponential moving average.

3840: <p>In the example of the arduino starter kit the point is to use a potenciometer to control a servo.</p>

<p>The code is </p>

<pre><code>angle = map(potVal, 0, 1023, 0, 179);
</code></pre>

<p>The output in the serial</p>

<pre><code>potVal: 1023, angle: 179
potVal: 1015, angle: 177
potVal: 1023, angle: 179
potVal: 1016, angle: 177
potVal: 1023, angle: 179
potVal: 1023, angle: 179
</code></pre>

<p>I noticed that the servo is shaking like trying to go passing over the 179, when it is suppose to use an angle max 180º (0-179)</p>

<p>What could be the problem?</p>
 3981: <p>Since the previous answers were all code-related, let me suggest you use a smoothing capacitor. In noisy environments, or where you want to get more consistent readings, place a capacitor across your signal lines (signal to ground). The result is less "spikes" in your readings, and can sometimes cause a slight delay in signal changes, as charge has to build up in the capacitor before the voltage goes up.</p>

<p><a href="http://www.learningaboutelectronics.com/Articles/What-is-a-smoothing-capacitor" rel="nofollow">http://www.learningaboutelectronics.com/Articles/What-is-a-smoothing-capacitor</a></p>
 220: <p>I like this method the best (personal preference) for smoothing signals:</p>

<pre><code>//In setup
int bufferedVal = analogRead(A0);
int unbufferedVal = analogRead(A0);
#define _TOLERANCE_ 5

//The loop
unbufferedVal = analogRead(A0);
if(abs(unbufferedVal - bufferedVal) &gt;= _TOLERANCE_ ) {
  bufferedVal = unbufferedVal;
}
</code></pre>

<p>This finds the error using the <code>abs()</code> function (absolute value; makes sure it is positive).</p>

<p>Another thing you can do is round it to the tenth placeholder (i.e. 88 -> 90, 83 -> 80) so it always is a good number to work with:</p>

<pre><code>int val = analogRead(A0);
val += 5;
val = val / 10;
val = val * 10;
</code></pre>

<p>The last two lines work because of the lack of precision that integers offer with decimals. If I divide 88 by 10, it doesn't output 8.8; it outputs 8 instead. We then multiply by ten again so it isn't 8 when it really should be 80. The only problem with this is it only rounds down. We can fix this by adding 5 (the halfway point between 10 and 0). That way, it goes: 88 to 93 to 9.3 to 9 to 90.</p>

<p><strong>NOTE:</strong> I'm not sure if the compiler will notice the redundancy of the last two lines. If it acts weird, try using the <code>volatile</code> keyword.</p>
 3917: <p>If the problem is due to jittery pot readings, you may want to smooth the <code>potval</code> data sequence by code like the following, where <code>rawreading</code> stands for what you just read from the potentiometer's input line.</p>

<pre><code>potval = alpha*potval + (1-alpha)*rawreading;
</code></pre>

<p>Set <code>alpha</code> to a number (eg 0.8 or 0.9 or 0.95 etc) between 0 and 1.  <code>alpha</code> represents the fraction of the old value that you retain, and  <code>1-alpha</code> represents the fractional influence of the new raw reading.   <code>alpha</code> closer to 1 causes smoother but slower response.</p>

<p>If you prefer integer arithmetic for faster or smaller code, then represent <code>alpha</code> as a ratio of integers.  For example:</p>

<pre><code>potval = (potval*12 + rawreading)/13;
</code></pre>

<p>The technique mentioned above is called <em><a href="http://en.wikipedia.org/wiki/Exponential_smoothing#The_exponential_moving_average" rel="nofollow">exponential smoothing</a></em> or  <em>exponential moving average</em>.</p>
