Electrical noise issue

I am using a sensor to detect humans. the sensor has an output high level of 12V so I used a buck converter to step down this to 5v and connected the output of the buck converter to the arduino input port. then added a relay to an arduino output port. when connecting the arduino VIA PC, the relay keeps turning on and off randomly although the power supply of 12v that is connected to the sensor is turned off and the sensor isnt supplying any signal. what can i do to solve this issue?

And the circuit diagram and code is …

What means that the Arduino receives garbage from an open input (antenna).

Which is not the right way.
Just use a voltage divider (two resistors).
10k between pin and ground and 15k between pin and sensor will drop 12volt to 4.8volt.

The advice could have been different if we had known which Arduino, which sensor, which relay module, and code you are using.
Leo..

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.