A couple things. In the second sketch, are you sure that
int data = Serial.read() -'5';
gives the intended value?
Also, the first sketch maps the analog input value to a number between 0 and 180 then sends it over the XBee. The second sketch then also maps it. A second mapping should not be necessary, yes?