Hello everybody. In this instructable I'll show you how to make easily a contactless switch with a distance sensor. It might be very useful for your house or other machines.

Because I'm a student and I'm making a project about 'Passive house' and I want to have a special switch.

Step 1: What You Need

What you need to make this switch, are:


-a breadboard

-a distance sensor. I prefer the HC-SR04 or a HC-SR05.

-an arduino board

-an LED to test the program

Step 2: Wiring

The distance sensor have 4 pins:






-VCC to 5V pin on your arduino board

-TRIG to a digital pin (in my case pin 3)

-ECHO to another digital pin (in my case pin 4)


Connect the LED to a digital pin, it has to be different from the other pins.

Step 3: Program

This is the code for the switch. Use my code if you wish.

Step 4: Result...

Sorry for my English. I'm not a native speaker. If you have any improvement, they are welcome!

<p>Sounds really interesting and I will try it . If you are interested (ignore this if not!) I think there are only two very small &quot;errors&quot; in your English:</p><p>&quot;1. A distance sensor have 4 pins: &quot; '1. The distance sensor has 4 pins.' </p><p>&quot;You can just take the mine to use it.&quot; Not quite sure what you mean, but I think it is </p><p>'Use my code is you wish.'</p>
<p>Did you test your code with an object approaching ?</p><p>You'll agree the code is redundant, but if it works...</p>
<p>Yes, I've tested my code with an object approaching and normally it should work. In my case, I've tested many times and it worked! So, why not?</p>
<p>Actually, I'm working on a similar project to dim my kitchen lights but there are too much reading errors even with delays. I'll try with &quot;while&quot; instead of &quot;if then else&quot;, that looks better, I'll let you know.</p>
<p>I'm also using the 'while' function instead of 'if else' and it works very well !</p>
<p>Cool. No contacts means that there are no parts to wear out.</p>
<p>What I mean about my project is that I want to make a switch to turn on ... (ex an LED) without touching the switch, just like a normal switch.</p>

About This Instructable




More by NguyenN90:The Samurai Head Make a Contactless Switch 
Add instructable to: