Arduino 4D LCD interface

I have an arduino + xbee (transmitter) communicating with a second set of arduino + xbee (receiver). there is a 4D LCD screen connected to the transmitter.
With this set up I am trying to achieve 2 things: 1. read a voltage measurement and display it on the LCD screen and 2. each Arduino has a high output, they have a respective LED light turn on.
I was not able to have both objectives run at the same time so I implemented a switch to go from one code to the other.
At times when the switch is flipped it successfully moves into the second loop, but it usually fails or seems to get stuck in a loop.

What is causing these faulty outputs?

transmitter.ino (540 Bytes)

receiver.ino (972 Bytes)

Can you post a wiring list that shows how everything is connected ?
Something isn't making sense. Maybe I am misinterpreting your post.

there is a 4D LCD screen connected to the transmitter.

Receiver code
voltLED = ((5.0 * analogRead(sensorPin) * 1000.0) / 1023); (Can you explain this math ? How did you arrive at this
formula ? What is this supposed to represent ? 5V dc input to A0 = 1023. Therefore 5V/1023= 0.0048875V (4.88mV).
Therefore,
Val= analogRead(A0);
Volts = 0.00488 * Val
Let input = 1V
1023/5=204 =>
Val= 204
Volts = 0.0048875204=0.9999825 (V)
Now let's try your code:
Let input = 1V
Val= 204
5.0 * analogRead(sensorPin) * 1000.0) / 1023);=> [5.0
(204)*1000]/1023=1020000/1023=997.067
voltMeter = voltLED/100;=>997.067/100=9.97 ? (SHOULD BE 1V or approx. , right ?)

If the sensor is connected to the Receiver, how do you expect to display the value on an lcd connected to the transmitter ? Does that make sense ? (the Transmitter transmits , the receiver receives, so why is the lcd connected to the transmitter ? Also, you don't have any switch debouncing code. If you are not going to use software debouncing you need a 1k resistor and a 1 uF capacitor RC lowpass filter to debounce the switch. Let's talk about that before we talk about the rest of the program.