# Distance Measurement with Ultrasound

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/061/954/medium800/sensors_hcsr04-wired-over-cpx-2800.jpg?1537106060 HC-SR04 ultrasonic sensor above a Circuit Playground Express board.)

The **HC-SR04** is an inexpensive distance sensor based on a pair of [ultrasonic transducers](https://en.wikipedia.org/wiki/Ultrasonic_transducer "Wikipedia: ultrasonic transducer") with a straightforward [TTL](https://en.wikipedia.org/wiki/Transistor%E2%80%93transistor_logic "Wikipedia: Transisor transistor logic") level interface and a claimed range of 2cm to 4m. Similar sensors are now commonplace with the widespread use of car parking assistance sensors.

Danger: 

This project demonstrates distance measurement in [Microsoft MakeCode](https://www.microsoft.com/en-us/makecode "Microsoft MakeCode") inspired by the [BBC micro:bit example](https://makecode.microbit.org/reference/pins/pulse-in "BBC micro:bit pulse in Makecode example for HC-SR04") starting with a very simple program and then showing more features of MakeCode and the Circuit Playground Express (CPX) board.

If you are new to using MakeCode, [check out the guide to getting started](https://learn.adafruit.com/makecode "What is MakeCode?") first.

Thank-you to George and Edward for the loan of their CPX board.

## Parts
### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
![A Black woman's manicured hand holds a round microcontroller with lit up LEDs.](https://cdn-shop.adafruit.com/640x480/3333-05.jpg)

### HC-SR04 Ultrasonic Sonar Distance Sensor + 2 x 10K resistors

[HC-SR04 Ultrasonic Sonar Distance Sensor + 2 x 10K resistors](https://www.adafruit.com/product/3942)
If you're like me, you've dreamed of being a dolphin - smoothly gliding through the water. Using your echo-location abilities to detect tasty fish treats. Until genetic modifications catches up with our desires, we'll just have to make do with these handy **HC-SR04 Ultrasonic...**

In Stock
[Buy Now](https://www.adafruit.com/product/3942)
[Related Guides to the Product](https://learn.adafruit.com/products/3942/guides)
![Video of a woman's hand rising above a blue ultrasonic sonar distance sensor plugged into a half-size breadboard. An OLED screen displays the rising distance between the woman's hand and the sensor.](https://cdn-shop.adafruit.com/product-videos/640x480/3942-04.jpg)

### Half Sized Premium Breadboard - 400 Tie Points

[Half Sized Premium Breadboard - 400 Tie Points](https://www.adafruit.com/product/64)
This is a cute, half-size breadboard with&nbsp;400 tie points, good for small projects. It's 3.25" x 2.2" / 8.3cm&nbsp;x 5.5cm&nbsp;with a standard double-strip in the middle and two power rails on both sides.&nbsp;You can pull the power rails off easily to make the breadboard as...

In Stock
[Buy Now](https://www.adafruit.com/product/64)
[Related Guides to the Product](https://learn.adafruit.com/products/64/guides)
![Angled shot of half-size solderless breadboard with red and black power lines.](https://cdn-shop.adafruit.com/640x480/64-06.jpg)

### Premium Male/Male Jumper Wires - 40 x 6" (150mm)

[Premium Male/Male Jumper Wires - 40 x 6" (150mm)](https://www.adafruit.com/product/758)
Handy for making wire harnesses or jumpering between headers on PCB's. These premium jumper wires are 6" (150mm) long and come in a 'strip' of 40 (4 pieces of each of ten rainbow colors). They have 0.1" male header contacts on either end and fit cleanly next to each other...

In Stock
[Buy Now](https://www.adafruit.com/product/758)
[Related Guides to the Product](https://learn.adafruit.com/products/758/guides)
![Angled shot of Premium Male/Male Jumper Wires - 40 x 6 (150mm)](https://cdn-shop.adafruit.com/640x480/758-04.jpg)

### Small Alligator Clip to Male Jumper Wire Bundle - 6 Pieces

[Small Alligator Clip to Male Jumper Wire Bundle - 6 Pieces](https://www.adafruit.com/product/3448)
When working&nbsp;with unusual non-header-friendly surfaces, these handy cables will be your best friends! No longer will you have long, cumbersome strands of alligator clips. These compact jumper cables have a premium male header on one end and a grippy mini alligator clip on the...

In Stock
[Buy Now](https://www.adafruit.com/product/3448)
[Related Guides to the Product](https://learn.adafruit.com/products/3448/guides)
![Group of Small Alligator Clip to Male Jumper Wires](https://cdn-shop.adafruit.com/640x480/3448-00.jpg)

Info: 

### US-100 Ultrasonic Distance Sensor - 3V or 5V Logic

[US-100 Ultrasonic Distance Sensor - 3V or 5V Logic](https://www.adafruit.com/product/4019)
If you're like me, you've dreamed of being a dolphin - smoothly gliding through the water. Using your echo-location abilities to detect tasty fish treats. Until genetic modifications catch up with our desires, we'll just have to make do with this handy **US-100 Ultrasonic...**

In Stock
[Buy Now](https://www.adafruit.com/product/4019)
[Related Guides to the Product](https://learn.adafruit.com/products/4019/guides)
![Video of a woman's hand moving toward ultrasonic sonar distance sensor plugged into a half-size breadboard. An OLED screen displays the distance between the woman's hand and the sensor.](https://cdn-shop.adafruit.com/product-videos/640x480/4019-03.jpg)

# Distance Measurement with Ultrasound

## Connect the Sensor

The common HC-SR04 boards are designed for 5V TTL voltage levels. Since the advent of [CMOS](https://en.wikipedia.org/wiki/CMOS "Wikipedia: CMOS") many circuits started using 3.3V levels including the CPX board, this can create compatibility problems. The guide to [CPX Pinouts](https://learn.adafruit.com/adafruit-circuit-playground-express/pinouts "Adafruit CPX Pinouts") states:

> All of the GPIO pads are 3.3V output level, and **should not be used** with 5V inputs. In general, most 5V devices are OK with 3.3V output though.

This creates a requirement to reduce the voltage from the **Echo** output of the HC-SR04 rather than simply directly connecting all of the sensor's pins to the CPX board. The easiest way to reduce a single voltage is to use two resistors as a [potential divider](https://en.wikipedia.org/wiki/Voltage_divider "Wikipedia: voltage divider"). The example shown uses two _equal_ resistors (10 K ohms, they come with the HC-SR04 that Adafruit sells) to halve the voltage. 2.5V is clearly lower than 3.3V but this is high enough to work. The sum of the two resistors should be above 1 kiloohm to keep the current within the limits of the sensor's output.

The slightly more complicated alternative to converting the voltages is to use a semiconductor solution like the unidirectional [74LVC245](https://www.adafruit.com/product/735 "74LVC245 - Breadboard Friendly 8-bit Logic Level Shifter") or [74AHCT125](https://www.adafruit.com/product/1787 "74AHCT125 - Quad Level-Shifter (3V to 5V)") or the bidirectional [TXB0104](https://www.adafruit.com/product/1875 "TXB0104 Bi-Directional Level Shifter").

The diagram below shows how to connect the components together. The HC-SR04 can be plugged directly into the breadboard without the four wires shown in the diagram.

![](https://cdn-learn.adafruit.com/assets/assets/000/062/761/medium800/sensors_cpx-hcsr06-breadboard-crocclipse_bb.png?1538400828)

The picture below shows how it looks implemented on a breadboard. The only _differences_ are: the sensor is plugged into the breadboard; the use of double-ended alligator (crocodile) clip leads with header pins aiding connection to the breadboard. The [alligator clip to male jumper wire](https://www.adafruit.com/product/3448 "Adafruit: Small Alligator Clip to Male Jumper Wire Bundle - 6 Pieces") is an easier alternative.

![](https://cdn-learn.adafruit.com/assets/assets/000/061/937/medium800/sensors_cpx-hcsr04-hires-i.jpg?1537054274)

The connections are:

&nbsp;

- Black: **Gnd** to **GND** via bus strip. Row 1 is also connected to ground.
- Red: **Vcc** to **VOUT** via bus strip **.**
- Green: **Echo** to potential divider (a pair of 10k resistors across).
- White: divided voltage (row 6) to **A1**.
- Yellow: **Trig** to **A2.**

&nbsp;

**Note: Pictures show two 2.2K resistors, Adafruit supplies two 10K resistors, both configurations function the same).**

![sensors_hcsr04-breadboardlabelled-700-i.jpg](https://cdn-learn.adafruit.com/assets/assets/000/061/935/medium640/sensors_hcsr04-breadboardlabelled-700-i.jpg?1537053477)

![sensors_hcsr04-echo-resistorvoltageadjust-700.jpg](https://cdn-learn.adafruit.com/assets/assets/000/061/936/medium640/sensors_hcsr04-echo-resistorvoltageadjust-700.jpg?1537053812)

The **A0** input can be used as an output for the sensor's **Trig** pin if you want the surprise of hearing the trigger pulses. The CPX board has **A0** hard wired up to its small speaker.

For comparison: the Raspberry Pi has the same 3.3V limitation on GPIO inputs; many of the Arduino boards like the Uno are 5V tolerant for inputs, allowing [direct connection](https://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/ "Instructables: Simple Arduino and HC-SR04 Example") of this sensor.

The standard HC-SR04 will appear to work at 3.3V but apparently is [far less accurate](https://www.raspberrypi.org/forums/viewtopic.php?p=183386#p183386 "Raspberry Pi Forum: Ultra cheap ultrasonics, and a bit of a challenge").&nbsp;There's a detailed discussion on some of the variations of this sensor on [David Pilling's HC-SR04 page](https://www.davidpilling.com/wiki/index.php/HCSR04 "David Pilling's HC-SR04"). Adafruit now sell the [US-100 Ultrasonic Distance Sensor](https://www.adafruit.com/product/4019 "US-100 Ultrasonic Distance Sensor - 3V or 5V Logic") which is 3.3V compatible.

# Distance Measurement with Ultrasound

## Simple MakeCode

This example calculates the distance from the response from the sensor, graphs it on the NeoPixels, beeps with a pitch based on distance and logs the value.

![](https://cdn-learn.adafruit.com/assets/assets/000/061/955/medium800/sensors_makecode-hcsr04-cpx-Ultrasound-Distance4-screenshot-nodecor-a.png?1537119236)

[Open this example in MakeCode](https://makecode.com/_6VCY9AgCdi4j)
The video (animated gif) below shows the sensor measuring the distance to a moving piece of paper and indicating this via the number of NeoPixels illuminated. The paper doesn't move far enough away to light up the tenth NeoPixel. There is a brief reading over the expected value, this could be due to the first reflection being missed and the sensor picking up sound from the the third reflection.

![](https://cdn-learn.adafruit.com/assets/assets/000/062/004/medium800thumb/sensors_hcsr04-cpx-makecode-demo1-600x450.jpg?1537221747)

## Description and Discussion

The code is a simple loop sending a pulse to **A1** output pin and then measuring the pulse on **A2** input pin with the MakeCode **pulse in pin** block. The division by 58 converts the timed value into centimetres and this value is then shown on the NeoPixels up to a value of 30cm (12"). The distance is also represented by a short beep with frequency (pitch) between 50Hz (for 0.25cm) and 10kHz (for 50cm). The distance is also logged but this is only visible if you are using the [Windows 10 app version of MakeCode](https://learn.adafruit.com/make-it-graph-plot/plotting-with-makecode "Plotting with MakeCode").

It's not clear if this sensor has a maximum measuring rate or a required pause after the **Echo** pulse before the next measurement. If it does then the code has a _minor flaw_ as it's relying on the console log as a delay if the distance is out of range for the beep to occur.

The value of 58 or 58.2 is often seen in example code. It's worth exploring where this "magic" number comes from. The **Echo** high pulse duration represents the time for the _first_ detected reflection. The [speed of sound](https://en.wikipedia.org/wiki/Speed_of_sound "Wikipedia: Speed of sound") varies mainly with temperature and to a far lesser degree by humidity. The chirp travels to the target _and_ is reflected back, its journey is _twice_ as long as the distance. 58 represents an assumption that the speed of sound is 1000000 / 58 \* 2 / 100 = 344.8 metres per second. 344.8m/s would equate to a 21.6 degrees Celsius (70.8 Fahrenheit), 40% [relative humidity](https://en.wikipedia.org/wiki/Relative_humidity "Wikipedia: relative humidity") day.

The [graph block](https://makecode.adafruit.com/reference/light/graph "Adafruit MakeCode: graph") logs the distance value to the console as an unnamed value making the use of [console log value](https://makecode.adafruit.com/reference/console/log-value "Adafruit MakeCode: console log value") block a little superfluous.

# Distance Measurement with Ultrasound

## More Advanced MakeCode

These are some more advanced examples showing how to use the temperature from the on-board thermistor, how to use the buttons to add extra functionality and how to implement your own graph on the NeoPixels.

# Distance Measurement with Ultrasound

## Speed of Sound

This example is the same as the first simple example but with added code to calculate the speed of sound based on the temperature from the CPX's [thermistor](https://en.wikipedia.org/wiki/Thermistor "Wikipedia: thermistor"). That temperature is then used to calculate the divisor for distance calculations.

![](https://cdn-learn.adafruit.com/assets/assets/000/061/956/medium800/sensors_makecode-hcsr04-cpx-Ultrasound-Distance-SOS3-screenshot-nodecor-a.png?1537120143)

[Open this example in MakeCode](https://makecode.com/_EVEfP1RMP4Df)
## Description and Discussion

This code introduces a new variable to store the temperature read from the thermistor in degrees Celsius. The speed of sound is then calculated using a formula. The number 273.15 may be familiar - it's being used to convert the temperature to [Kelvin](https://en.wikipedia.org/wiki/Kelvin "Wikipedia: Kelvin").

The potential flaw from the original code is fixed with the addition of a 62 millisecond delay when the distance is out of range for a beep. At 120bpm, a [demisemiquaver (1/32 note)](https://en.wikipedia.org/wiki/Thirty-second_note) is 4 \* 60 / 120 / 32 \* 1000 = 62.5ms.

The temperature is also logged to allow it to inspected to ensure the value is reasonable and accurate.

A good question is whether the temperature needs to be calculated every time a new distance is measured. As temperature does not typically change much this could be performed once. A single calculation would be problematic if the code was expected to run for a long time or the temperature was expected to change rapidly. At the cost of increased complexity of code, one compromise solution would be to calculate it periodically with the period based on the likely rate of change. Sample rate decisions like this become more relevant when the calculation is more intensive and there are limited resources.

# Distance Measurement with Ultrasound

## Range Selection

This example is the same as the first simple example but with added code to allow the left button to mute the beeping and the right button to change the maximum range. The [on start](https://makecode.adafruit.com/blocks/on-start "Adafruit MakeCode: on start") block is introduced to initialise some variables include two&nbsp;[arrays](https://makecode.adafruit.com/types/array "Adafruit MakeCode: array").

![](https://cdn-learn.adafruit.com/assets/assets/000/061/957/medium800/sensors_makecode-hcsr04-cpx-Ultrasound-Distance-Multiplerange1-screenshot-nodecor-a.png?1537120778)

![](https://cdn-learn.adafruit.com/assets/assets/000/061/958/medium800/sensors_makecode-hcsr04-cpx-Ultrasound-Distance-Multiplerange1-screenshot-nodecor-b.png?1537120801)

[Open this example in MakeCode](https://makecode.com/_aLE2sXCH1UfY)
## Description and Discussion

The three maximum range distances are stored in the `rangelist` array with some associated colours in `huelist` (0 is red, 85 is green, 170 is blue in this [HSV model](https://en.wikipedia.org/wiki/HSL_and_HSV "Wikipedia: HSL and HSV")). `rangeindex` is used to select the current range from `rangelist`. The first element in an array in MakeCode is 0, in other languages this may be 1.

The loop is similar to the first example but with the addition of two `if` blocks to deal with buttons `A` (left) and `B` (right) and a more sophisticated condition for beeping which now uses the same range as graphing and constrains the frequency between 100Hz and 8kHz.

The check for `button A` uses a common subtraction technique to toggle between the two volume values, 0 and 128. `button B` looks more complicated but is only adding 1 (incrementing) the `rangeindex` and then returning to the first element if it has gone past the end of the array. The code flashes all the NeoPixels the `pixelhue` colour for 1 second to indicate to the user which range has been selected, e.g. green for 100cm.

There is a subtle but important difference between the code for the two buttons. The first uses [was pressed](https://makecode.adafruit.com/reference/input/button/was-pressed "Adafruit MakeCode: was pressed") and the second uses [is pressed](https://makecode.adafruit.com/reference/input/button/is-pressed "Adafruit MakeCode: is pressed"). `was pressed` checks for any press since the last check but `is pressed` _only_ checks as the block is executed. In this case the code before the `if` blocks executes quickly hence everything loops frequently allowing the use of the instantaneous `is pressed`. Holding down either button for a few seconds will reveal a difference in behaviour relating to this.

MakeCode also has an [on](https://makecode.adafruit.com/reference/input/button/on-event "Adafruit MakeCode: on") block which is an alternative method for coding for buttons. The volume mute could also have been implemented using a&nbsp;[boolean](https://makecode.adafruit.com/blocks/logic/boolean "Adafruit MakeCode: boolean") value and controlled using [set volume](https://makecode.adafruit.com/reference/music/set-volume "Adafruit MakeCode: set volume") although the CPX default level sounds like 20 rather than 128. It is common in computer languages for there to be more than one way to achieve the same goal.

Info: 

# Distance Measurement with Ultrasound

## New Graph v1

This example is the same as the first simple example but with the native&nbsp;[graph](https://makecode.adafruit.com/reference/light/graph "Adafruit MakeCode: graph") block replaced by a new one with a higher precision representation on the NeoPixels.

![](https://cdn-learn.adafruit.com/assets/assets/000/061/959/medium800/sensors_makecode-hcsr04-cpx-Ultrasound-Distance-Newgraph1a-screenshot-nodecor-a.png?1537120926)

![](https://cdn-learn.adafruit.com/assets/assets/000/061/960/medium800/sensors_makecode-hcsr04-cpx-Ultrasound-Distance-Newgraph1a-screenshot-nodecor-b.png?1537120939)

[Open this example in MakeCode](https://makecode.com/_1sXiEihi4Lvd)
The new graphing code calculates the value in terms of number of pixels but keeps the remainder from the calculation and varies the brightness of the final pixel based on that remainder to show values "between" the NeoPixels. The video below demonstrates the sensor being moved (just visible on the left) to indicate how the NeoPixels represent the distance values.

![](https://cdn-learn.adafruit.com/assets/assets/000/061/967/medium800thumb/sensors_hcsr04-cpx-makecode-newgraph-demo1-480x360.jpg?1537128062 HC-SR04 sensor being moved to show varying brightness from new graphing.)

The code has an `if` block with a `true` value. This looks a little odd but allows the programmer to switch between the two versions of the graphing for comparison. This could be removed if the programmer has made a decision to only use one type of graphing.

The NeoPixels visibly flicker when many of them are lit. The code sets them all to black and then sets each one that needs to be on or partially on. There are more efficient approaches to this. A key change is to use the `set buffered` and `show` blocks to apply the changes in one go when they are all done.

# Distance Measurement with Ultrasound

## New Graph v2

This example is the same as the [first graphing version](https://learn.adafruit.com/distance-measurement-ultrasound-hcsr04/new-graph-v1 "New Graph v1") but places the graphing code in a&nbsp;[function](https://makecode.adafruit.com/types/function "Adafruit MakeCode: function") called `newgraph`.

![](https://cdn-learn.adafruit.com/assets/assets/000/061/961/medium800/sensors_makecode-hcsr04-cpx-Ultrasound-Distance-Newgraph1b-screenshot-nodecor-a.png?1537121137)

![](https://cdn-learn.adafruit.com/assets/assets/000/061/962/medium800/sensors_makecode-hcsr04-cpx-Ultrasound-Distance-Newgraph1b-screenshot-nodecor-b.png?1537121148)

![](https://cdn-learn.adafruit.com/assets/assets/000/061/963/medium800/sensors_makecode-hcsr04-cpx-Ultrasound-Distance-Newgraph1b-screenshot-nodecor-c.png?1537121158)

[Open this example in MakeCode](https://makecode.com/_2qYgo0Yq9Ahc)
## Description and Discussion

In this particular case the use of a `function` does not make a huge amount of difference. It makes the `forever` loop more compact and a little easier to read. If all of the code from the previous examples were combined then the `forever` loop would become unwieldy. If the code is difficult to understand and review then [bugs](https://en.wikipedia.org/wiki/Software_bug "Wikipedia: software bugs") are more likely to creep in.

Functions become more useful in a program when they are used (called) multiple times as they reduce code duplication. They can also be the first step towards sharing code between different programs.

# Distance Measurement with Ultrasound

## The Ultrasound Pulses

![](https://cdn-learn.adafruit.com/assets/assets/000/061/925/medium800/sensors_hcsr04-logicanalyser-threemeasurements.png?1537034015 Logic analyser showing three distance measurements.)

A logic analyser can be used to look at the communication between the CPX board and sensor. It can also be connected to the ultrasonic transmitter to see the high frequency chirp but won't work on the unamplified receiver output. A basic logic analyser cannot show the full detail of the analogue voltages as it makes everything appear rectangular. There are some examples of what the signal really looks like on [David Pilling's HC-SR04 page](https://www.davidpilling.com/wiki/index.php/HCSR04 "David Pilling's HC-SR04").

![](https://cdn-learn.adafruit.com/assets/assets/000/061/926/medium800/sensors_hcsr04-logicanalyser-onemeasurement.png?1537034194 Logic analyser showing one distance measurement.)

The screenshot at the top of the page shows three distance measurements. The screenshot just above is one of the measurements zoomed in showing:

- **Trig** (yellow): the pulse requesting the sensor to make a measurement,
- **Tx Pulses** (blue): the actual burst of eight pulses which constitute the ultrasonic chirp,
- **Echo** (green): the sensor's output measured by the logic analyser as 858 microseconds.

The 858 microseconds divided by 58 gives 14.8cm. The target was placed at 15.0cm which suggests this can be very accurate. The voltage thresholds for low and high on the logic analyser may differ by a tiny amount compared to the CPX board.

The **TX Pulses** can be used to determine the audio frequency. Using a higher resolution trace made at 25MHz, measuring seven pulses from the leading edge for best accuracy gives 173.24 microseconds, 7 / 173.24 \* 1000 = 40.41kHz, clearly in the ultrasound range.

# Distance Measurement with Ultrasound

## Going Further

## Ideas for areas to explore

- Finding something fun to measure!
- Seeing if your pet can hear the sensor, some animals can hear ultrasound.
- Checking the maximum range for different objects and the behaviour of the sensor for no reflection ("infinity").
- Checking and explaining the behaviour for very close objects.
- Adding calibration offsets and coefficients to the program based on testing with one or more sensors.
- Determining if sensors can be confused by other sensors operating in the same space.
- Measuring the cone angle for the sensor and exploring physical techniques for reducing this.
- Testing if fast movement affects sensor's ability to measure distance.
- Exploring techniques for enhancing accuracy for stationary objects.
- Checking the behaviour of the standard HC-SR04 at 3.3V.
- Testing the 3.3V tolerant HC-SR04 variants. These may be red and labelled as "1652".
- Explore other similar sensors like the (single transducer) Maxbotix range and ones that use different techniques:
  - SHARP sensors with infrared arrays,
  - STMicroelectronics Time of Flight (ToF) sensors.

## Further Reading

- [Element 14: The Learning Circuit 85: How Do Ultrasonic Distance Sensors Work?](https://www.element14.com/community/docs/DOC-96017/l/the-learning-circuit-85-how-do-ultrasonic-distance-sensors-work?CMP=SOM-TWITTER-PRG-E14PRESENTS-LCIRCUIT-EP85 "Element 14: The Learning Circuit 85: How Do Ultrasonic Distance Sensors Work?") (video)

Featured
### IR distance sensor includes cable (20cm-150cm)

[IR distance sensor includes cable (20cm-150cm)](https://www.adafruit.com/product/1031)
This SHARP distance sensor bounces IR off objects to determine how far away they are. It returns an analog voltage that can be used to determine how close the nearest object is. Comes with 8" long 3-JST interface wire. These sensors are good for detection between 20cm-150cm. For over 1 m...

In Stock
[Buy Now](https://www.adafruit.com/product/1031)
[Related Guides to the Product](https://learn.adafruit.com/products/1031/guides)
![Angled shot of a IR distance sensor with cable.](https://cdn-shop.adafruit.com/640x480/1031-02.jpg)

Featured
### Adafruit VL53L0X Time of Flight Distance Sensor - ~30 to 1000mm

[Adafruit VL53L0X Time of Flight Distance Sensor - ~30 to 1000mm](https://www.adafruit.com/product/3317)
The **VL53L0X** is a&nbsp;_Time of Flight_&nbsp;distance sensor like no other you've used! The sensor contains a very tiny invisible laser source, and a matching sensor. The VL53L0X can detect the "time of flight", or how long the light has taken to bounce...

In Stock
[Buy Now](https://www.adafruit.com/product/3317)
[Related Guides to the Product](https://learn.adafruit.com/products/3317/guides)
![Video of a white hand hovering over a Adafruit VL53L0X Time of Flight Distance Sensor that's connected to a white breadboard reading the range of motion of the white hand. ](https://cdn-shop.adafruit.com/product-videos/640x480/3317-03.jpg)


## Guide Products

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
### HC-SR04 Ultrasonic Sonar Distance Sensor + 2 x 10K resistors

[HC-SR04 Ultrasonic Sonar Distance Sensor + 2 x 10K resistors](https://www.adafruit.com/product/3942)
If you're like me, you've dreamed of being a dolphin - smoothly gliding through the water. Using your echo-location abilities to detect tasty fish treats. Until genetic modifications catches up with our desires, we'll just have to make do with these handy **HC-SR04 Ultrasonic...**

In Stock
[Buy Now](https://www.adafruit.com/product/3942)
[Related Guides to the Product](https://learn.adafruit.com/products/3942/guides)
### Half Sized Premium Breadboard - 400 Tie Points

[Half Sized Premium Breadboard - 400 Tie Points](https://www.adafruit.com/product/64)
This is a cute, half-size breadboard with&nbsp;400 tie points, good for small projects. It's 3.25" x 2.2" / 8.3cm&nbsp;x 5.5cm&nbsp;with a standard double-strip in the middle and two power rails on both sides.&nbsp;You can pull the power rails off easily to make the breadboard as...

In Stock
[Buy Now](https://www.adafruit.com/product/64)
[Related Guides to the Product](https://learn.adafruit.com/products/64/guides)
### Premium Male/Male Jumper Wires - 40 x 6" (150mm)

[Premium Male/Male Jumper Wires - 40 x 6" (150mm)](https://www.adafruit.com/product/758)
Handy for making wire harnesses or jumpering between headers on PCB's. These premium jumper wires are 6" (150mm) long and come in a 'strip' of 40 (4 pieces of each of ten rainbow colors). They have 0.1" male header contacts on either end and fit cleanly next to each other...

In Stock
[Buy Now](https://www.adafruit.com/product/758)
[Related Guides to the Product](https://learn.adafruit.com/products/758/guides)
### Small Alligator Clip to Male Jumper Wire Bundle - 6 Pieces

[Small Alligator Clip to Male Jumper Wire Bundle - 6 Pieces](https://www.adafruit.com/product/3448)
When working&nbsp;with unusual non-header-friendly surfaces, these handy cables will be your best friends! No longer will you have long, cumbersome strands of alligator clips. These compact jumper cables have a premium male header on one end and a grippy mini alligator clip on the...

In Stock
[Buy Now](https://www.adafruit.com/product/3448)
[Related Guides to the Product](https://learn.adafruit.com/products/3448/guides)
### US-100 Ultrasonic Distance Sensor - 3V or 5V Logic

[US-100 Ultrasonic Distance Sensor - 3V or 5V Logic](https://www.adafruit.com/product/4019)
If you're like me, you've dreamed of being a dolphin - smoothly gliding through the water. Using your echo-location abilities to detect tasty fish treats. Until genetic modifications catch up with our desires, we'll just have to make do with this handy **US-100 Ultrasonic...**

In Stock
[Buy Now](https://www.adafruit.com/product/4019)
[Related Guides to the Product](https://learn.adafruit.com/products/4019/guides)
### Maxbotix Ultrasonic Rangefinder - LV-EZ1

[Maxbotix Ultrasonic Rangefinder - LV-EZ1](https://www.adafruit.com/product/172)
LV-EZ1 Maxbotix Ultrasonic Rangefinder provides very short to long-range detection and ranging, in an incredibly small package. It can detect objects from 0-inches to 254-inches (6.45-meters) and provides sonar range information from 6-inches out to 254-inches with 1-inch resolution. (Objects...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/172)
[Related Guides to the Product](https://learn.adafruit.com/products/172/guides)
### IR distance sensor includes cable (20cm-150cm)

[IR distance sensor includes cable (20cm-150cm)](https://www.adafruit.com/product/1031)
This SHARP distance sensor bounces IR off objects to determine how far away they are. It returns an analog voltage that can be used to determine how close the nearest object is. Comes with 8" long 3-JST interface wire. These sensors are good for detection between 20cm-150cm. For over 1 m...

In Stock
[Buy Now](https://www.adafruit.com/product/1031)
[Related Guides to the Product](https://learn.adafruit.com/products/1031/guides)

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [Ultrasonic Sonar Distance Sensors](https://learn.adafruit.com/ultrasonic-sonar-distance-sensors.md)
- [Raspberry Pi E-Ink Event Calendar using Python](https://learn.adafruit.com/raspberry-pi-e-ink-desk-calendar-using-python.md)
- [Breadboards for Beginners](https://learn.adafruit.com/breadboards-for-beginners.md)
- [Chinese Dragon Puppet with Motion-Reactive Flame Effect](https://learn.adafruit.com/chinese-dragon-puppet-with-motion-reactive-flame-effect.md)
- [3D Printed Heel Clips](https://learn.adafruit.com/3d-printed-heel-clips.md)
- [Make It Glow With Crickit](https://learn.adafruit.com/make-it-glow-with-crickit.md)
- [Wind Blowing Emoji Prop](https://learn.adafruit.com/wind-face-emoji.md)
- [CircuitPython Snow Globe](https://learn.adafruit.com/circuitpython-snow-globe.md)
- [Sparkle Skirt Playground](https://learn.adafruit.com/sparkle-skirt-playground.md)
- [CircuitPython on the Arduino Nano RP2040 Connect](https://learn.adafruit.com/circuitpython-on-the-arduino-nano-rp2040-connect.md)
- [Paper Craft Zoetrope with Crickit](https://learn.adafruit.com/paper-craft-zoetrope-with-circuit-python.md)
- [Circuit Playground Express Serial Communications](https://learn.adafruit.com/circuit-playground-express-serial-communications.md)
- [Trellis Feather DSP-G1 Synthesizer](https://learn.adafruit.com/feather-trellis-dsp-g1-synthesizer.md)
- [reef-pi Guide 1: Setup and Demonstration](https://learn.adafruit.com/reef-pi-installation-and-configuration.md)
- [Bunny Ears with MakeCode](https://learn.adafruit.com/bunny-ears-with-makecode.md)
- [Circadian Pi Desk Light](https://learn.adafruit.com/circadian-pi-desk-light.md)
