Acoustic Radar Display




About: 55+ years in electronics, computers, and teaching ... now retired.

This instructable describes how to make an ultrasonic “radar-style” display using an Arduino microcontroller, an ultrasonic sensor, and a small stepping motor.

An optional sensor modification allows multiple objects to be detected with each ping.

Construction is simple ... all you need are two drills, a sharp knife, a pair of side-cutters , and a soldering iron.

Photo 1 shows the basic parts. The “insert” shows a random-dot test pattern. Dots representing primary objects are shown in red ... dots representing secondary objects are shown in blue.

Photo 2 shows the assembled unit.

Photo 3 shows an actual screen shot of seven objects. [1]

The video clip shows the unit in operation.


The azimuth and distance of each primary object are shown in red. Any echo from a secondary object is shown in blue. Without the sensor modification you will only see the red objects.

Since the sonic pulses expand in a cone-like manner, distant objects appear wider. The actual bearing of each object is the midpoint of each continuous (red or red/blue) line.

Continuous lines containing both red and blue dots are a single object, part of which is in shadow.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Wiring Diagram

The wiring diagram is shown in photo1.

An optional modification is shown in photo2. This modification is the SAME for both the HC-SR04 and the HY-SRF05 ultrasonic sensors and allows multiple echos to be detected. [1]


For a full explanation see my instructable

If you have an HC-SR04, the integrated circuit to which you solder the wire is labelled U2

Step 2: Parts List

The following parts were obtained locally:

  • 1 only plastic food container.
  • 1 only sub-miniature micro-switch.
  • 1 only male header strip (used for attaching wires from sensor).
  • 1 only female header strip (used to mount sensor).
  • 1 only piece of 20 gauge aluminium (scrap) sheet 40mm x 55mm.
  • 6 only 9mm nylon spacers tapped 3mm.
  • 3 only cable-ties.
  • 13 only 3mm x 6mm bolts.
  • 1 only 3mm nut.
  • 4 only 4mm x 10mm bolts.
  • 2 only 4mm nuts.

The following parts were obtained from

  • 1 only Arduino Uno R3 microcontroller complete with USB cable.
  • 1 only 28BJY-48 5 volt stepping motor complete with ULN2003 controller.
  • 1 only 5mm bore brass hex shaft to wheel coupler for model cars.
  • 1 only HY-SRF05 (or HC-SRF04) ultrasonic sensor.

Step 3: How It Works


All parts are housed inside a plastic food container. Power is obtained from your USB port.

The circuit comprises an Arduino, an ultrasonic sensor, a stepping-motor, and a micro-switch for moving the sensor to its “home” position. The micro-switch is necessary as it is not possible to rotate the stepping motor by hand due to its 64:1 internal gearing.

When first powered up the Arduino rotates the sensor to its “home” position, as determined by the micro-switch, then “polls” the display until it gets a response.

The 28BJY-48 stepping motor has a “stride angle” of 5.625/64 degrees which means that 1 degree steps are not possible (even though our graticule is labelled 0..180 degrees).

Fortunately, 180/stride-angle = 180*64/5.625 = 2048 which is evenly divisible by 8. If we increment a number from 0..2048 and divide by 8 there are 256 occasions when we get a remainder of zero ... we simply send a “ping” whenever the remainder is zero. This equates to a “ping” every PI/256 radians or 0.703125 degrees.

Software [1]

The display then takes control and continually asks the Arduino to supply the following data:

  • Azimuth
  • Distance1
  • Distance2
  • Direction

The “distance(s)” for each “azimuth” are then displayed on the screen. The “direction” information is used to create the illusion of “dots” appearing behind the “beam” as it rotates.

The Arduino automatically moves to the next “ping” position whenever data is sent to the display.


The “Processing 3” software used for writing the display may be downloaded from

Processing 3 supports 2D and 3D graphics and is very similar to the Arduino IDE (Integrated Development Environment). The main visual differences are a “graphics window” when the code is running and the use of a “draw()” function instead of the Arduino “loop()”.

Step 4: The Display

The Graticule

I chose to create a 180 degree graphics display as it provides a “radar shadow” in which to stand while experimenting. Such a display is also compatible with a servo motor should I wish to use one. A full 360 degree display can be obtained by tweaking the code.

The following photos explain how the graticule was created:

Photo 1

  • The graticule comprises a number of “arcs” and “lines”. Angled labels are shown in this photo but were later dropped in favour of horizontal text which is easier to read.

Photo 2

  • Shows a red line depicting the “beam”. The text in the label is now horizontal.

Photo 3

  • The red line in photo 2 has been rotated 0..180 degrees through 256 azimuth positions. In this photo the outer parts of the graticule are not covered as the beam-width is too narrow. This results in some strange artifacts.

Photo 4

  • Increasing the beam-width has eliminated these artifacts.

Photo 5

  • Random dots have been introduced to represent primary (red) and secondary (blue) echos. The range, which can be changed, has been set to exactly 100cm to match the display. A fading beam pattern has also been introduced. The technique used to create this “fading beam” is explained further on.

Photo 6

  • The color scheme has been changed to add a touch of realism.


The animated portions of the graphics display use 3D graphics to greatly simplify the code. To understand how this is possible let’s draw a “30 degree line” of constant radius from an XY start coordinate of (0,0).

2D graphics requires the use of sin(30) and cos(30) to calculate the XY end coordinates of the line:

X=cos(30)*radius = 0.866*radius
Y=sin(30)*radius = 0.5*radius

3D graphics doesn’t require the use of trigonometry. We simply rotate the XY grid coordinates about the Z-axis then draw a horizontal line .... no maths required!!!

pushMatrix();		//preserve our current grid coordinates
rotateZ(radians(30));	//rotate our XY grid coordinates about the Z-axis
line(0,0,radius,0);	//draw a “horizontal” line on the rotated grid
popMatrix();		//restore our grid coordinates

Either way works but this second method lends itself to “ping” intervals of PI/256 radians.

Fading Lines

The fading beam pattern uses a clever technique found at

The beam is given its own virtual screen. Prior to drawing any line the “alpha” (opacity) of all previous lines is reduced by a small amount. Ultimately the earliest lines become invisible which gives the illusion of a fading “fan” pattern.

This virtual screen, which is never erased, is then merged with the contents of the main screen whenever the display is refreshed.

Step 5: Mounting Bracket

The drilling template for a suitable mounting bracket is shown in photo 1.

Position the two outer “mount” holes below the transmit (T) and receive (R) sensors. I find that best results are obtained if the sensor rotates around the receive (R) sensor rather than midway between the two sensors. The three holes allows you to experiment.

Details of how to “cut and fold” aluminium may be found in my instructable

Step 6: Assembly

USB cable-hole

Do not try and drill a cable-hole for the USB connector though the side of the plastic container as plastic tends to split and chip. Instead, melt a hole using the tip of a hot soldering iron then trim with a sharp knife. Take care not to breath the fumes.


Replace one of the 4mm “grub-screws” in the shaft-extender with a 4mm x 10mm bolt. This bolt is used to activate the micro-switch.


Position the micro-switch such that it is activated by the 4mm bolt when the shaft rotates in a clockwise direction.

I used two turns of 20 gauge copper wire to attach the micro-switch to the case as 2mm nuts and bolts were not readily available.

Remaining components

Layout is not critical. The motor shaft was positioned centrally. The Arduino and motor controller were mounted on nylon spacers which allow the wires to be tucked underneath.

Mounting the sensor

Photo 1

  • shows the sensor assembly. The HY-SR0F-5 socket has been fashioned from a female-header socket. All unwanted pins have been removed and a 3mm hole drilled through the plastic. The header is then attached to the bracket by means of a 3mm nut and bolt.

Photo 2

  • shows a side view of the sensor assembly. The wires from the header are cable-tied to the bracket. This “strain-relief” prevents unwanted cable movement as the sensor rotates. Note also the “grey” wire attached to pin 10 of IC1. This wire is optional and feeds the secondary echos to the Arduino.

Attach the sensor assembly to the shaft extender after the micro-switch has operated following power-up. The shaft is then in its “home” position.

Step 7: Software Installation

Install the following code in this order:

Arduino IDE

Download and install the Arduino IDE (integrated development environement) from if not already installed.

Processing 3

Download and install Processing 3 from

Acoustic Radar Sender [1]

Copy the contents of the attached file, “acoustic_radar_sender_2.ino”, into an Arduino “sketch”, save, then upload it to your Arduino Uno R3.

Close the Ardino IDE but leave the USB cable connected.

Acoustic Radar Receiver

Copy the contents of the attached file, “acoustic_radar_receiver.pde” into a Processing “Sketch”.



"acoustic_radar_sender_2.ino" fixes a "scan-creep" bug in "acoustic_radar_sender_1.ino" . My thanks to for pointing it out.

Step 8: Testing

Click the top left “Run” button in your Processing window and your project will burst into life.

Try detecting different objects:

  • Nearby objects require the transmit (T) sensor to be low to prevent the "beam" passing over the top.
  • More distant objects require a larger surface area as much of the acoustic energy is lost as the beam spreads ... plus the return echo also spreads.
  • Experiment with the three mounting holes.
  • You may wish to try mounting the sensor vertically so that the transmit and receive beam-widths overlap.

  Click here   to view my other instructables.

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    45 Discussions


    Question 11 months ago

    Hi im a student of the damiaaninstituut at aarschot in belgium
    we had to choose a project from this site and i chose this
    i think its a cool and nice project
    but i have a problem
    everytime i try to start the progam i get this error :
    Error opening serial port COM1: Port busy

    1 answer

    Answer 11 months ago

    The software for "Acoustic Radar Display" must be loaded in the following sequence:
    The Arduino software
    (1) Connect a USB cable between your Arduino and your PC
    (2) Click "Tools|Port" then select your Arduino serial port number.
    (3) Upload the Arduino sketch to your Arduino
    (4) Leave the USB plugged in to your PC
    (5) Close your Arduino IDE ... it is no longer required
    Processing 3 Software
    (1) Now run the Processing 3 sketch
    Possible error messages
    You will get an error message if:
    (1) the Arduino USB cable is not plugged in to the PC.
    (2) The Processing serial port is not the same as that used to program the Arduino
    (3) The error message that you describe indicates that you have tried to upload software to your Arduino while the Processing sketch is running.


    Question 1 year ago on Step 1 you know of a way to send the video to a 4 wire oled display? Trying to make a 1 inch radar screen for a 1/10 scale model boat.



    1 answer

    1 year ago

    Can of Watties!!! This guy's a Kiwi!

    Excellent Instructable, lots of fun and very well presented. It looks like the radar prefers the Baked Beans...


    1 reply

    1 year ago

    How far can those sensors detect objects? Can they work at say 2-3 metres distance?

    1 reply

    Reply 1 year ago

    The HC-SR04 and HY-SRF05 sensors have a maximum range of around 4 meters. I have restricted this range to 1 meter in my code.


    1 year ago

    Super project! Got it working without too much trouble; thank you *lingib*, for an excellent instructable.

    The two main issues I had before getting this project to work were ... figuring out how to tweak the "Processing" sketch to talk to the Arduino IDE, and a bad connection, which was totally my own fault (too embarrassing to explain, but ... I forgot to solder something(s)!) All of this was achieved by following the instructable to the letter. This success emboldened me to try running the project on a Pro-Mini, which worked just fine ... then I tried a Nano, which worked fine as well. The idea behind trying these smaller footprint Arduinos being that I had the notion to build the whole thing into a smaller box.

    The box I eventually chose had enough space inside to accommodate a couple of Li-ion cells in series to power the stepper; I preferred this to driving it directly from the Uno. I also included an on/off switch for this battery stepper supply, and a reset push switch for the Uno (handy for me to have, given my method of repeat testing). Right now I have a completed, as specified, functional Acoustic "Radar" unit that has only one cable; USB to the PC.

    One thing I'd like to try is to extend the range beyond 1m ... some guidance on this would be appreciated?

    Being introduced to "Processing" has been a big step forward for me so, thanks for that, too.

    I have a small video of the first success on the bench, before the sensor was mounted, so it's just sitting there static.

    Just remembered to mention this as well ... only for fun, I added a small laser head to the rotating sensor that tracks (points to) the reflecting surface ... nice visual effect and, as I say, just for fun.

    I really enjoyed building this project ... thanks again lingib :-)

    2 replies

    Reply 1 year ago

    Well done ... your video is great :)

    To double the 100cm radius to 200cm radius:

    (1) double the numbers in

    // ----- label the arcs

    fill(255); //light gray text

    textAlign(LEFT, BOTTOM);

    text("100cm", +5, -width/2); //"100cm"

    text("75", +5, -width/2*0.75); //"75cm"

    text("50", +5, -width/2*0.5); //"50cm"

    text("25", +5, -width/2*0.25); //"25cm"

    // ----- new code follows

    text("200cm", +5, -width/2); //"200cm"

    text("150", +5, -width/2*0.75); //"150cm"

    text("100", +5, -width/2*0.5); //"100cm"

    text("50", +5, -width/2*0.25); //"50cm"

    (2) Change the following four code lines in

    // =======================

    // plot data

    // =======================

    stroke(255, 0, 0); //set data1 color to red

    if (Ping[index][0]>100) Ping[index][0] = 1000; //hide by printing off-screen

    ellipse(width/2*Ping[index][0]/100, 0, 5, 5); //plot data1

    stroke(0, 0, 255); //set data2 color to blue

    if (Ping[index][1]>100) Ping[index][1] = 1000; //hide by printing off-screen

    ellipse(width/2*Ping[index][1]/100, 0, 5, 5); //plot data2

    // ----- new code follows

    stroke(255, 0, 0); //set data1 color to red

    if (Ping[index][0]>200) Ping[index][0] = 1000; //hide by printing off-screen

    ellipse(width/2*Ping[index][0]/200, 0, 5, 5); //plot data1

    stroke(0, 0, 255); //set data2 color to blue

    if (Ping[index][1]>200) Ping[index][1] = 1000; //hide by printing off-screen

    ellipse(width/2*Ping[index][1]/200, 0, 5, 5); //plot data2


    Reply 1 year ago

    Thank you lingib, this modification works as it says on the proverbial tin! Your swift response to my wish has been superb; thank you for that too.

    Best wishes ...


    Question 1 year ago

    I followed your tips about the connected state and it does appear to be connected, i'm seeing values like you showed in your screenshot, but my motor still isn't moving. The UNL lights aren't lighting up at all. I ran a separate test of the UNL and stepper, worked fine. Is it possible it's because there's no statement to include a library? I'm so close :-)

    2 answers

    Answer 1 year ago

    No additional libraries are required ... the code should just run.


    Answer 1 year ago

    Check that:

    (1) Check that the link on the ULN2003 controller is present. Removing that link removes power to the motor and you won't see any lights.

    (2) Check that 5 volts is getting to the ULN2003 controller.

    (3) None of the lights will light when the motor is first turned on as all outputs will be zero.The motor should be rotating if your display is seeing code. Check, with a voltmeter that voltage is appearing on the IN1, IN2, IN3, IN4 input pins. (I have not tried this but you could disconnect say IN1 and apply 5 volts directly, via a 560 ohm .. or 1000 ohm resistor to that pin ... if the controller is okay then one of the lights should light).

    (4) Is it possible that something is jamming the motor shaft?

    (5) Check also your wiring ... I tape my arduino connections as they have a habit of falling out. It only takes one pin.


    Question 1 year ago

    Love this idea and am trying to make it but running into issues. My motor doesn't move (I tested it on it's own, works fine) and the terminal is just repeating S over and over and I just can't figure out the issue. I don't have a microswitch so I set that value to false like in the comment but still no luck. Any suggestions? Oh I also am using the 04 ultrasonic w/out the optional connection if that helps.