I've been having problems on how to interface the signal of the LJC18A3-H-Z/BY. Which runs HIGH on signal when something is detected. I tried running the signal through a resistor pull-up using a 10k resistor. The voltage of the signal of the sensor wasn't enough to make the signal back to the arduino be HIGH. I've done this because I have the pin 2 on INPUT and as you may know may cause electrical noise. INPUT_PULLUP was the thing I don't know if possible because the sensor signals high when something is detected. I am a beginner at this. Sorry if I was wrong or didn't know something. Thank you!
Quick Specs:
Product Name: Proximity Switch
Specifications Model: LJC18A3-H-Z / BY
Tip diameter: ~15mm
Dimensions: 70 x 30 mm
Detection Method: Capacitive
Output Type: PNP, NO
Detection Range: +- 10 mm
Detecting: metal and non-metallic such as plastic, glass, water, oil
Operating voltage: DC 6 to 36V
Weight: 84g
Please post a link to the specs of your sensor, a schematic showing us how you wired it and your code (in code tags). Please read the forum guide in the sticky post at the top of the forum if you are unsure how to post any of these things.
Do I still need schematic? I only have the signal of the sensor connected to Pin 2/D2. And the sensor is connected to a 12v power supply. I tried to make it work on an led, it turned on when it detected something.
Only if you want the forum to be able to help you. If you do not post it, we will have to rely on our crystal balls. I have to tell you, they don't work so good. Hand-drawn schematic is OK.
Read the forum guide in the sticky post at the top of the forum section. This will tell you what to post and why you need to post it.
There is no common ground between the Arduino and the 12V supply. Without that common ground, the Arduino cannot read the signal.
This may mean that a 10K pull-down resistor is needed between the Arduino pin and ground.
What voltage does the sensor output? If it outputs anything above 5V, that could damage the arduino. Measure the output voltage with your multi-meter before you connect it to the arduino pin.
If you are supplying the switch with 12 volts, it will put near 12 volts on it's output wire, you need a voltage divider or switching transistor. Do not connect directly to Arduino input pin.
Also wouldn't the 10k resistor heat up because gnd is coming from 12v. I accidentally added a 220 ohm resistor to the gnd from the 12v and it heated up pretty fast.
If wired correctly, 12V output from the sensor would drive 0.000428 Amps through the series connection of R1 (18000Ω) and R2 (10000Ω), total 28000Ω, Power dissipated by resistors would be about 0.005 Watts or 5 milliWatts, not enough to warm a flea's behind. That current flowing through R1 (18k) would cause a voltage drop of about 7.7V and P of 3.3mW, through R2, 4.28V and 1.8mW.
Are you sure you have the right components and wiring is correct?
What are the wire colors on your switch? What color is connected to what?