Arduino Projects

Arduino ultrasonic sensor Relay


In This Tutorial, We Are Going To Learn How You Make Your Own Automatic Light Control with the help of an ultrasonic Sensor.

We are just trying to create a small automated light when you seat in your chair then the light automatic will open and if you do not seat in the chair that’s Time the Light Will be Off.

We just set the ultrasonic Sensor in the range of 50m if you want to change it then you just edit in code and put your requirement.

Bill Of Materials

These are all Components We Used In this Project




Link To Buy


Arduino Nano



Ultersonic Sensor (HC-SR04)



Relay module



Zero PCb


Arduino Nano

Arduino nano
Arduino nano

Components2 1


Ultrasonic Sensor


Relay Module

Components1 1

Circuit Diagram

Here We Design A Circuit diagram, In this Circuit diagram We used an Arduino nano Microcontroller And Ultrasonic Sensor (HCSR-04) We Also used A 5v 1 channel Realy Module To Control the Ac(230v) Light.

The Ultrasonic Sensor Will Connected To Pin numbers 5 And 4 and the relay will connect to Pin Number 10.

Ultrasonic Sensor 

  • VCC – 5v
  • TRIG – 5
  • ECHO – 4
  • GND – GND

Relay Module

  • VCC – 5v 
  • OUT – 10
  • GND – GND


Arduino Ultersonic And relay

PCB Design 

We Just Design A Sample PCB You easily interface the ultrasonic sensor and relay module in this PCB we used multiple sensors.

This PCB Is relay good For Al Beginners.

PCB Design3

PCB Design3 1

PCB Design2

PCB Design1

Source Code

Here We gave the Code You just Select the proper Board In Arduino ide Software And Then Upload It. Also, You Change the Distance in Your requirement.

Demo Of Projects

Now I will Just Show The Demo of the Project, See if the Distance Is More then 50cm then the Light Will be OFF.

Screenshot 2023 01 11 at 3.03.36 AM

When the Distance Is Less Than 50cm then the light will be On

Screenshot 2023 01 11 at 3.03.26 AM

Video Tutorial


If You are Interested In More Projects Then Plz Check it


If you Like Do Share Your Feedback on this Arduino Project. Very Thank You For Your Time 😊


Hi, Prateek Here I’m interested in Electronics That's why I Make Soo Many Projects, I’m currently Pursuing M Tech.. if you Relay Like To My Blog Plz Comment Below...Thanks To All Electronics Lover...❤️

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker