Goal
Build a swiveling scanner that turns real objects into computer graphics, using one infrared distance sensor, two servos, an Arduino, and readily available materials. The sensor sweeps a wide range of angles from a single pivot point, and the readings are converted from spherical to Cartesian coordinates to map the shape.
My part
On the mechanical side, I chose two different servo sizes: a larger one at the bottom for the pan axis, and a smaller one on top for tilt. I designed and printed the second servo housing and a holder for the sensor that puts its receiver exactly on both rotation axes, so every reading comes from the single pivot point the coordinate conversion assumes. Then I assembled the scanner.
On the software side, I set up a live connection between MATLAB and the Arduino, processed the calibration data into a distance model, got the scanning script working, added the coarse-then-fine pass, and wrote the post-processing that turns raw points into a shape.
Calibration
The sensor’s datasheet says voltage is linear in 1/distance at useful ranges, so we fit the form a/(V + b) + c. It beat an exponential fit on both R² and maximum error. At short distances the curve folds back on itself, with two distances for one voltage, so the domain is limited to more than 6 inches.
D(V) = 12035.51 / (V + 141.35) − 9.87, with D in inches and V as the 0–1023 analog reading.
Calibration data and the fitted curve. Readings closer than about 6 inches were discarded.
Coarse, then fine
A scan runs in two passes. The coarse pass sweeps a large area in 4–5° steps. MATLAB then keeps only the plausible points (not too close, not too far, not below the table), draws a bounding box around 90% of them so a few outliers can’t blow it up, and pads it by 5° to catch the edges. The fine pass rescans just that box in 1–3° steps.
From points to a shape
Post-processing filters twice and then flattens. First it drops points more than one standard deviation from the mean distance. Then it fits a plane with PCA, where the cross product of the two strongest components gives the normal, and drops points more than one standard deviation from that plane. Everything left is projected onto the plane. In one scan, more than 900 of about 2,000 points survived, which was plenty of resolution.
Raw points from the coarse and fine passes.
Results
Our own test cutout, a letter A scanned from about 18 inches, came out accurate, though the thin top was less certain.
The first test scan: the letter A.
A major source of error is how the sensor’s signal spreads. Its analog reading doesn’t come from a single point, so when the sensor points slightly to the side of a large object, that object can still bleed into the reading.
The final scan was a crying-face cutout from the course assistants, pictured at the top of this page. It kept its round shape, eyes, eyebrows, and tears, though the mouth came out too large and one tear stream is less defined than the other.



