[mircemk] shows how to create a simple non-contact proximity sensor using little more than an Arduino Nano board, and a convenient software library intended to measure the value of capacitors.
The iPhone's proximity sensor is one of its handier built-in features ... and then press and hold the power/lock button until you see the Apple logo. On an iPhone 7 or 7 Plus, press and hold ...