analog read problem

I am trying to use an analog value coming from one arduino board into another to control a sequence on the second board.
At the moment I just send an analog signal from a PWM pin on the main board that steps through 4 increasing values every few seconds.
This bit seems to be working. But on the second board I am reading the value and trying to get it to light up one led at a time to simulate different points in a sequence that I will write later.
This bit is not working.
I have included the code
Any ideas welcome
Mark

int ledPinA = 2;
int ledPinB = 3;
int ledPinC = 4;
int ledPinD = 5;
int value;        //value for analog read


void setup()
{
pinMode(ledPinA, OUTPUT);
pinMode(ledPinB, OUTPUT);
pinMode(ledPinC, OUTPUT);
pinMode(ledPinD, OUTPUT);
}  


void ModeA()
{
  digitalWrite (ledPinA, HIGH);
  digitalWrite(ledPinB, LOW);
  digitalWrite(ledPinC, LOW);
  digitalWrite(ledPinD, LOW);
}

void ModeB()
{
  digitalWrite (ledPinB, HIGH);
  digitalWrite(ledPinA, LOW);
  digitalWrite(ledPinC, LOW);
  digitalWrite(ledPinD, LOW);
}

void ModeC()
{
  digitalWrite (ledPinC, HIGH);
  digitalWrite(ledPinA, LOW);
  digitalWrite(ledPinB, LOW);
  digitalWrite(ledPinD, LOW);
}

void ModeD()
{
  digitalWrite (ledPinD, HIGH);
  digitalWrite(ledPinA, LOW);
  digitalWrite(ledPinB, LOW);
  digitalWrite(ledPinC, LOW);
}


void loop()
{
  value = analogRead(0);      //read analog value from main controller
  
  
 if (value < 256)
 {
   ModeA();
   
 }
 
  if (value > 256 && value < 512 )
 {
   ModeB();
   
 }
 
  if (value > 512 && value < 768)
 {
  ModeC();
   
 }
 
 if (value > 1023)
 {
 ModeD();
   
 }
  
  
}

This bit is not working.

In what way is it not working?

Remember that PWM outputs are not true analog outputs, but pulse-width modulated digital outputs. You will need to do some averaging in analog hardware (smoothing, or low-pass filtering) to get a true analog signal.

But why do you need to do this in the first place? Are you trying to communicate a numerical value from one Arduno to another, over a wire? If so, you may find that a digital method works better.

I was originally trying to do this because I thought I had run out of pins so I thought I could use one analog in set to 4 different values to trigger 4 separate responses (this requires 2 digital pins).
As it happens I have just found my project does not require as many pins as I thought so I can use the digi pns after all.

Thanks for replying anyway - I would still be interested in knowing more about reading a PWM input more reliably. I found some averaging code and stuck a simple bit of smoothing via a resistor and capacitor but the PWM still fluctuated so much that I could only distinguish 3 levels across the range from 0 to 5 volts.

I'm putting this down to lack of experience becuase I am very new to the arduino

I'm putting this down to lack of experience

I would put it down lack of a decent size capacitor. Try 1uF and 680R.