Im finally getting somewhere with it. Ive got it to recognise when serial data is being sent and ive got it to fade the bulb out using the sync with the zero crossing. There is still a problem that remains. The serial data that comes in is being currupted. I have a feeling this is to do with that RS232 inverter you mentioned.

Ive seen examples on the net saying serin2 can use inverted and non-inverted serial. Can i use non-inverted here too? At the moment i have a 100K resistor from VSS to RX and a 330ohm resistor from the serial port to RX. That is how i normally do it and it works with serin2.

I used your code example to echo the input back to the PC. I sent it numbers from 1 to 100 but it replied with completely diff numbers. They appear to be random but they arnt because if i send the same value twice i get the same value back twice.

I think im so close now. PWM is working and i can program the chip to make the lights fade out Its just sorting this last serial problem out and hopefully i can start work on the real program