Coding an Ultrasonic Sensor as an input

Hi Guys

Im doing a project which is creating a self driving car and im needing help with the coding of the Ultrasonic Sensor. Basically im using the sensor as an input to a servo motor. Im needing a "when the sensor detects something the servo will turn on".

Just some guidance would be a big help


Im using an Arduino Uno Board.

Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.,148850.0.html

Can you tell us your electronics, programming, arduino, hardware experience?

You need a library for arduino called NewPing.

The library may already be in your IDE, so first look up Examples, if its there, load "NewPingExample", using HC-SR04, sonar unit, it will give you a basic distance display.

Hope this helps.

What servo do you have?

The key to coding is to do it in stages, getting each stage working before ging to the next.

Tom... :slight_smile:

Servos are normally permanently “turned on”