Simple C programming Question

I have gone through the example sketches and have been successful, even modifying some for different delays and pins.

Then, I've merged the Blink, Servo and Parallax PIR Rev B Motion Detector Sketches into a test sketch. Right now, I am trying to detect motion and turn on/off the onboard LED. No matter what value is returned from the motion detector via a digitalRead, the LED is always turned on. Either my variable assignment or the logical test is wrong, but at this time, I can't determine which.

The debug output is as follows. Whenever the integer value is 0, I am expecting the message to be "detected LOW".

detected HIGH
1   detected HIGH
1   detected HIGH
0   detected HIGH
0   detected HIGH
0   detected HIGH
0   detected HIGH
0   detected HIGH

My code is attached below:

// Sketch to blink prop eyes when someone approaches.
// Behavior can be modified depending on how long they stay
// Test version blinks LED


#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
 
int motionPin = 2;  // analog pin used to connect the motion detector
int motionVal;      // variable to read the value from the analog pin 

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

void setup() {
  Serial.begin(9600);

  // initialize the servo on pin 9
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 

  // initialize the digital pin as an output.
  pinMode(led, OUTPUT); 
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW

// Allow the motion detector to warm up.
  delay(20000);
}

void loop() {

  motionVal=digitalRead(motionPin);
  Serial.println(motionVal);
  
  if (motionVal = 1) {
    digitalWrite(led,HIGH);
    Serial.println("detected HIGH");
  }
  
  if (motionVal = 0) {
    digitalWrite(led,LOW);
    Serial.println("detected LOW");
  }
   
  delay(200);
}

(deleted)

if (motionVal = 1) ...

if (motionVal = 0)  ....

You are using the assigment operator (=) instead of the equals operator (==). Change it to the following ...

if (motionVal == 1) ...

if (motionVal == 0)  ....

Ah hah!

I've figured it out, by looking at other examples. My comparison operators were wrong. The test should have been:
if (motionVal == 1) ...

The sketch is working as expected now.

Thanks to you all. Our replies crossed in the ether, but I wanted to thank you for your answers.