digital output is always high

Hi, I’m a noob with programming and I wan’t to learn to understand it a little bit. Thats why I recently bought a arduino to control the lights on the stairs
To control the light I also bought a ldr and a weight sensor.

in text:
If I put my foot on the weight sensor and it’s dark, the relay is high.
Else the relay is low.

I tested a lot and it was working with 1 sensor but not with 2.

This is my code.


const int m = A1; // pressure sensor
const int x = A2; // ldr
const int r = 3; // relay

const int ldrw = 200;
const int psen = 800;

void setup()
  pinMode(r, OUTPUT);
  pinMode(x, INPUT); // ldr
  pinMode(m, INPUT); // pressure sensor

  while (! Serial); //


void loop()

  // read sensors
  Serial.println(analogRead(m)); // pressure sensor
  Serial.println(analogRead(x)); // ldr
  delay (500);

  int  y = analogRead(m); //pressure sensor
  int  z = analogRead(x); //ldr

  if (y > psen && z < ldrw);
    digitalWrite (r, HIGH);

  if (y < psen && z > ldrw);
    digitalWrite (r, LOW);

I uploaded the code to my arduino and he set the relay alway high. When I open the serial monitor I see 2 value’s

  • apr. 2 for the pressuresensor
  • apr. 700 for the ldr.

I hope you can help me.


  if (y > psen && z < ldrw);oops

  if (y > psen && z < ldrw);oops

Maybe it’s obvious but I don’t understand what you mean :-[

In all the examples you've seen, you never seen a line like that, that ends like that.

void setup() {
  if (6 == 9);
    Serial.println(F("six is nine"));
void loop() {}
Somewhere\TrailingSemi\TrailingSemi.ino:3:14: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]

   if (6 == 9);

six is nine

Tanks for the reply's (sorry for the late response) but it is working now. AWOL tanks I was blind.