Do not try to connect directly to mains! you will instantly fry the pic, probably start a fire, and possibly kill yourself. to measure mains voltage you need to run through a transformer to lower the voltage. it also needs to be rectified. the pics inputs must be 5v max or less if running at lower voltage. and they cannot handle negative voltages. as far as using analog inputs you set it all up. you can make pins digital or analog on a per pin basis. you'll need to reference the data sheet to see which pins the adc uses, and what registers need to be set up.