control relays using ultrasonic sensors

good night master
sorry I am a newbie

I'm working on the final project in my school
I want to create a simulation of oil using ultrasonic level control and relay

I would like to ask about the program to drive the relay using ultrasonic, so if the distance oil to the ultrasonic already 20cm then delay 5s and ultrasonic would make the relay to ON

please help me about the program master
please
thank you

Do you know anything about arduino, programming or electronics?

Do you have any hardware? Have you read the information on designing a project that is supplied on this forum under "Programming Questions"?

It is a simple program to do but we are here to help with problems but not to do your school project for you.

Weedpharma

First thing you need to do is examine the datasheets for those two items, the ultrasonic and the relay.

Then forget about the relay for a while and get the ultrasonic working by itself: get it for example to turn the led on pin 13 on and off according to your requirements.

Then you can probably use that same output to control the relay. BUT you need to be very careful to understand your relay properly first so you don't get voltages and currents screwed up. Is your relay just a plain relay?- if so you will need a transistor to control it. If it's a relay on a breakout board, those boards usually have the electronics built in and you can take the Arduino i/o to the module. But make sure you understand it before you connect it.