Skip to main content
typo
Source Link
Sim Son
  • 1.9k
  • 14
  • 21

a == digitalRead(2) must be a = digitalRead(2). You also better change the if clause to if(a) to avoid true/HIGH/1 confusions.

If you had formatted the code properly, you'd have safed some time (you just need to select the code and press the {} button).

You also better replace the relay with a voltage divider (as I mentioned in my comment), because as long as you don't have a datasheet for the sensor you can't be sure that the sensor is designed to source that much current. If the sensor is supposed to drive a TTL logic, it will eventually fail, just like you don't drive relays with GPIOs directly. And beside that you need a freewheeling diode accrossacross the relay coil to deal with back EMF which will also harm the sensor.

a == digitalRead(2) must be a = digitalRead(2). You also better change the if clause to if(a) to avoid true/HIGH/1 confusions.

If you had formatted the code properly, you'd have safed some time (you just need to select the code and press the {} button).

You also better replace the relay with a voltage divider (as I mentioned in my comment), because as long as you don't have a datasheet for the sensor you can't be sure that the sensor is designed to source that much current. If the sensor is supposed to drive a TTL logic, it will eventually fail, just like you don't drive relays with GPIOs directly. And beside that you need a freewheeling diode accross the relay coil to deal with back EMF which will also harm the sensor.

a == digitalRead(2) must be a = digitalRead(2). You also better change the if clause to if(a) to avoid true/HIGH/1 confusions.

If you had formatted the code properly, you'd have safed some time (you just need to select the code and press the {} button).

You also better replace the relay with a voltage divider (as I mentioned in my comment), because as long as you don't have a datasheet for the sensor you can't be sure that the sensor is designed to source that much current. If the sensor is supposed to drive a TTL logic, it will eventually fail, just like you don't drive relays with GPIOs directly. And beside that you need a freewheeling diode across the relay coil to deal with back EMF which will also harm the sensor.

added 479 characters in body
Source Link
Sim Son
  • 1.9k
  • 14
  • 21

a == digitalRead(2) must be a = digitalRead(2). You also better change the if clause to if(a) to avoid true/HIGH/1 confusions.

If you had formatted the code properly, you'd have safed some time (you just need to select the code and press the {} button).

You also better replace the relay with a voltage divider (as I mentioned in my comment), because as long as you don't have a datasheet for the sensor you can't be sure that the sensor is designed to source that much current. If the sensor is supposed to drive a TTL logic, it will eventually fail, just like you don't drive relays with GPIOs directly. And beside that you need a freewheeling diode accross the relay coil to deal with back EMF which will also harm the sensor.

a == digitalRead(2) must be a = digitalRead(2). You also better change the if clause to if(a) to avoid true/HIGH/1 confusions.

If you had formatted the code properly, you'd have safed some time (you just need to select the code and press the {} button).

a == digitalRead(2) must be a = digitalRead(2). You also better change the if clause to if(a) to avoid true/HIGH/1 confusions.

If you had formatted the code properly, you'd have safed some time (you just need to select the code and press the {} button).

You also better replace the relay with a voltage divider (as I mentioned in my comment), because as long as you don't have a datasheet for the sensor you can't be sure that the sensor is designed to source that much current. If the sensor is supposed to drive a TTL logic, it will eventually fail, just like you don't drive relays with GPIOs directly. And beside that you need a freewheeling diode accross the relay coil to deal with back EMF which will also harm the sensor.

added 150 characters in body
Source Link
Sim Son
  • 1.9k
  • 14
  • 21

a == digitalRead(2) must be a = digitalRead(2). You also better change the if clause to if(a) to avoid true/HIGH/1 confusions.

If you had formatted the code properly, you'd have safed some time (you just need to select the code and press the {} button).

a == digitalRead(2) must be a = digitalRead(2). If you had formatted the code properly, you'd have safed time.

a == digitalRead(2) must be a = digitalRead(2). You also better change the if clause to if(a) to avoid true/HIGH/1 confusions.

If you had formatted the code properly, you'd have safed some time (you just need to select the code and press the {} button).

Source Link
Sim Son
  • 1.9k
  • 14
  • 21
Loading