Skip to content

Commit bcba4da

Browse files
committed
Add docs for ultrasound function on arduino
1 parent 57f4814 commit bcba4da

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

programming/arduino/sr_firmware.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,20 @@ However, for simple electronics, a microswitch for example, you would normally b
128128
However, the built-in pull-up resistor alleviates this need.
129129
It essentially wires in a resistor connected to 5.0V, meaning that when this option is enabled, an input pin will "default" to being high.
130130
This means you can simply connect a switch between the input pin and a ground pin without any need of resistors - when the switch is open, the pin will read high; when closed, it will read low.
131+
132+
## Ultrasound Sensors
133+
134+
You can also measure distance using an ultrasound sensor from the arduino. Ultrasound sensors return the distance of the closest object in mm.
135+
136+
```python
137+
# Trigger pin: 4
138+
# Echo pin: 5
139+
140+
# Measure distance in mm
141+
distance_mm = robot.arduino.ultrasound_measure(4, 5)
142+
```
143+
144+
<div class="warning">
145+
The ultrasound sensor can measure distances up to 4 metres.
146+
If the ultrasound signal has to travel further than 4m, the sensor will timeout and return 0.
147+
</div>

simulator/simulated_robot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ They return the distance to the nearest object in front of the sensor in a narro
6565
Objects beyond 4 meters are not detected.
6666

6767
The robot has four ultrasound sensors attached to it, one on each side of the robot.
68-
They can all be accessed using the Arduino API's [ultrasound interface]({{ site.baseurl }}/programming/arduino/sr_firmware#ultrasound).
68+
They can all be accessed using the Arduino API's [ultrasound interface]({{ site.baseurl }}/programming/arduino/sr_firmware#ultrasound-sensors).
6969

7070
<div class="info">
7171
Since these sensors rely on echoes being reflected back from objects, if the angle of incidence between the sensor's pulse and the contacted surface exceeds 22.5 degrees then the sensor will be unable to detect the object.

0 commit comments

Comments
 (0)