Trying to measure the speed of light with an Arduino

We know that measuring the speed of light with an Arduino is possible. It’s just that the implementation is hard.

Last month we saw [Udo]‘s blinkenlight shield that can be used as a line scan camera. It’s a neat piece of kit, but [Udo] really wants to submit something for the Buildlounge laser cutter giveaway, so he figured measuring the speed of light would be an easy project. If a kid and a chocolate bar can do it, surely it can’t be too hard.

[Udo] hit upon the idea of pulsing a laser pointer and measuring the time of the reflection. Because his blinkenlight shield can be used as a light sensor, all that’s needed is a mirror and a pretty long line of sight. There’s a few problems with the setup though: with the Arduino running at 16 MHz, a photon will travel 19 meters in one clock cycle.

Even with some very clever coding, we’re not really sure detecting an emitted photon is possible at such (relatively) slow clock speeds. We’re thinking [Udo] could source a few hundred meters of optic fiber so the entire experiment could fit on a desk, but feel free to drop a note in the comments if you’ve got a better idea. [Udo]‘s demo of his blinkenlight/laser mashup is after the break.


  1. brsnow says:

    Use multiple mirrors. The alignments get more critical for every mirror you add but you can add a lot of distance in a small space by bouncing it several times back and forth between mirrors. That’s how the eye doctors test distance vision in a 10′ long room. 1 mirror will get you 2x the length of your desk, placing emitter and sensor side by side 2 mirrors will get you 4x your desk, 3 will get you 6x and so on. With a visible laser setting up the alignment shouldn’t be too difficult.

  2. Tim says:

    For reference, it should take light 3.3 nanoseconds to travel 1 meter.

    You would require a clock frequency of about 10ghz to (0.1ns period) pin down the speed of light with a reasonable amount (lets say 5%) of error.

    Also since hes ‘measuring’ the speed of light over a distance of a few centimeters, with electrical signals which also travel a few centimeteres, and also travel at a speed of C, I would suspect that the systematic error is very large.

    • Infidellic says:

      I agree, this has to be one of the most inaccurate experiments going. Hell the wires to/from the daughterboard alone are about as long as the distance the light traveled. AND clock cycles (for that all important accuracy that’s being ignored) are being wasted on the LED array

      • roboman2444 says:

        he also has to take into account the time for the laser to activate… its not exactly instant from the exact time that the microcontroller pulls a pin to high.

        hm… he could probably more accurately measure the speed of electricity through a 100-1000 meter coil of wire. (its slower than light through a vacuum)
        He could also see if different configurations of the coil made differences. Shape, wire thickness, and if there was any sort of core would probably change it a bit.

      • Measuring pulse times in a long cable isn’t so simple, since you must account for a relatively big capacitance that may seriously slow down the pulse rise time (depending on output pin drive strength).

    • Roger Wolff says:

      Remember that electrical signals do NOT travel at the speed of light.

      Interesting experiment that you can do if you have a scope and a breadboard….

      Get yourself a schmitt trigger inverter (74HC14 works great). Make an oscilator with the first inverter, run it through a second inverter, then through 10 or 20m of electrical cable, and then through another inverter. Run both the beginning and the end of the cable through another inverter and show them both on your scope. Put the scope at its fastest and you’ll be able to get an idea of the speed of transmission of signals through electrical wires.

      Note that if you run two wires parallel and ground the second wire at the receiving end, transmission speed drops by 50% compared to grounding at the other end.

      I measured around 10^8 m/s for the higher speed, while most references you can find now on the internet will quote something more like 2 * 10^8 m/s. Apparently I had a measurement error in there somewhere.

      But still the order-of-magnitude was OK for a 10 minute dorm-room-experiment…..

  3. Hmm… Seems like you need to know when the beam actually leaves the laser. Maybe try 2 sensors/shields with a distance between them. That way you can correlate the 2 values and determine the trigger time?

    • rizsi says:

      And by measuring the arrival time of the light at two different light detectors you could eliminate all the systematic errors of signal propagation time in the electronic part of the measurement.

      You could also beef up your arduino to run faster. Or use a new x86 processor at 4GHz :-).

      Measuring frequency and wavelength seems to be easier though.

  4. Jas says:

    He’s not accounting for the rise time of the Nd solid state laser, which is going to dominate his measurement here.

    I think if I were trying to do this with an AVR, I’d hook my light detector to the SPI input and have the hardware clock it faster than the core; that would give me more resolution, though you’re still very limited. What is really needed is a free-running timer at several hundred MHz and a latch that fires when the pulse comes back.

    The reason it works with the chocolate bar is that the microwave radiation is at a frequency of about 2.4 GHz, giving a very short wavelength that is easily measured…

    • lwatcdr says:

      Ad a beam splitter and have a second detector very close to the laser and use that to start the clock. It might be more interesting to try different methods and see how close you get to what the professionals get.

  5. I’d also be hesitant to use the ADC (as I’m sure it is). Might be good to design a good ol analog circuit that triggers a digital interupt.

  6. lee says:

    could this be formulated as a probability?
    something like, i have a mirror or something spinning at x rpms. i know that the mirror is exposed for some amount of time, and not exposed for some other amount of time, lets say 50:50 for simplicity. so if i could detect every interval on off, meaning i had a pretty fast clock rate, i would get 50 detections per minute at 100 rpms (very fake numbers). Since my clock is slow lets do this experiment a bunch of times. and try to converge on 50.
    similarly lets do this with light now.
    send the signal and try to receive it. is our new probability
    Pr(REC) = Arduino_Clock_Time/Time_for_Light
    in this case its (1/16mhz) and c*d, where d is the round trip distance.
    so c = (16×10^6*Pr(REC)*d)^(-1).
    however since its assumed that the arduino is pretty deterministic, we need to add some randomness to the pulses so we can ‘fill out’ the edges of the clock sequence. To do this, we could combine our two experiments. Spin the mirror on and off on one side, and receive on the other. This has the added benefit of not making the arduino do the work.
    now to solve for light we have to know the spin velocity and then count the number of REC’s vs the number of RECs we should have received.
    OK that’s all for now, im no physicist so don’t trust what i say.

  7. monopole says:

    Ur doing it wrong! The clockspeed of the Arduino is quite sufficient if you work smarter not harder.

    Given a linescan camera a laser pointer and a fast electric motor there is a very accurate way of measuring the speed of light, the Foucault method.

    A Dremel would work for the motor.

    The nice thing about this is that you can increase the accuracy by simply moving the fixed mirror (or better yet a corner cube) out a longer distance.

  8. lee says:

    what about eps_0 and mu_0, constants permeability of magnetic and permittivity of electric space? light is an EM wave, and its velocity is magically equal to 1/sqrt(eps_0 mu_0).

  9. jimbob says:


    next week on HAD, opening inter dimensional portals with an arduino, some tinfoil, and a potato.

    *** this post sponsored by > arduino < ***

  10. DavidMP says:

    You cannot use a fibre to measure the speed in air/vacuum (they are pretty close). Light travels at different speeds in different media; you can bend the path using mirrors.

    How about a continuous laser going though a circular chopper (a slit on a CD) a second chopper before a photo-diode. You start with both of them sinchronised so you always see the light on the diode, then you slow one of them enough until you do not get a signal.

    • medix says:

      Actually, you CAN use fiber. Spools of it of several kilometers can be had for a reasonable price.

      The problem lies in the fact that your light ‘pulse’ will gradually spread during propagation (dispersion), causing the rising edge of the pulse to become obscured (though it may still work – I’ve never tried this method).

      You can work the numbers out to make this a viable option, provided you have enough length to give you a delay which is longer than your max clock frequency.

      • Hiro Protagonist says:

        Yeah, you Can use fibre – but the speed of light is significantly less in fibre.

        You need to use an interferometer.
        Mount a slotted disk on a shaft & spin it. Fire laser through slot @ 12 o’clock towards a mirror.
        Behind the disk is a circle of photodiodes.
        Which photodiode sees the reflection?

      • Mike says:

        Complex. There is a very simple analog method to do this and it is very precise.

      • medix says:

        “You can work the numbers out to make this a viable option, provided you have enough length to give you a delay which is longer than your max clock frequency.”

        Hiro, this is what I was talking about. With slower velocity, an ‘easily measurable’ delay is more likely.

        An interferometer can also be built with fiber.

  11. Matthew says:

    We did something nearly identical in my physics class this semester. We varied the intensity of a laser with a frequency generator, which we bounced off a mirror at various distances away between 1 and 10 meters. We used an oscilloscope to see the shift between the generated frequency and the detected frequency in ns and then plotted it versus our distances to find the speed of light. Even without factoring in the electronics and the wires we used (multiple at 1-2 meters each) we still managed to calculate the speed of light within 10%.
    Taking a bunch of measurements at different distances and fitting a line to it is a way to get around the low time resolution of the arduino (at least to some degree). Even though I think with the 16 MHz limit, you would need a VERY large range of distances.

  12. Would be better off sending out a FM radio wave and mixing on the return, then measuring beat frequency vs input frequency to determine distance, sorta like a doppler radar except the measured variance is from the emitted FM signal rather than actual doppler effect.

  13. tim says:

    Easy, just start charging a capacitor when the laser pulse start and stop charging when the light come back to the photodiode (pin diode is fast).
    Use fast logic gates and fast comparator.
    Use your arduino to measure the charge of the cap.

    That’s it

  14. I agree.. Capacitor should work. 2 sensors. Use a comparator that charges the cap when the outputs are different. The difficulty will be balancing the inputs.

  15. andres says:

    could you have a really fast counter going and gate it with the light sensor. send out light, run the counter at a couple megahertz, if not gigahertz, then stop the timer on the return light pulse?

  16. Mike says:

    Digital simply won’t cut it.

    We developed a laser range finder based on analog techniques. It can measure down to 6mm over 10m.

    We are considering developing an Arduino shield with market interest.

    If interested, let me know.

  17. Sean says:

    CD burner laser diodes can be pulsed at reasonably high frequencies using a 5v capable oscillator IC (I have tested 2.048Mhz), and many photodiodes have rise times significantly less than 10 ns. Use the 50% duty cycle from the oscillator, one photodiode to measure the initial signal and another to measure the reflected one. Combine signals naively. The measured duty cycle should be different from “expected”.

    @5Mhz, the ON time should be 0.1 usec. If your light travels 15m between the diodes, that should take 0.05 usec. Should give you 75% duty cycle all of a sudden. A dedicated counter IC would be best for measurement, but the arduino may work directly.

    Please verify my math though. I am tragically uncaffeinated at this moment.

    • Dax says:

      I believe they can be modulated from dim to bright, but not completely on/off because it takes a small jolt in voltage to start the lasing.

      • jbb says:

        Very true. In order to get a nice clean pulse out of the laser it might be best to start off with the laser at low power (say 10%) and then bump it up to 100% for the pulse. Use a nice low duty cycle to prevent self-heating of the laser.

        Also, most laser driver systems provide regulated current to the laser, so a switched current source could be a good move — but you would have to modify or replace the laser driver PCB.

        There is probably a photodiode built into the laser as well which could be useful for measuring the outgoing pulse from the laser. You should then use two fast comparators with AC coupling to reject background light and adjustable levels to trigger the capture unit of the AVR. With a 16 MHz clock you will have a resolution of 9.375 m/count. (Remember the light has to go out to the target and back.) Obviously the faster the clock the better your resolution could be.

        You could stick a bit of reflecting safety tape to your target to get more light back to your detector, which has got to help.

        Time of Flight (TOF) rangefinding is pretty tricky.

        Sorry for long post.

  18. Rhyno says:

    Phase shift. Measure the difference between a modulated beam at origin and the phase shift in the return signal. If you pick a frequency that’s easy to measure but fast enough to have changed during time-of-flight, you can determine that TOF from the amount of phase shift. Lots of simple math, but doesn’t require a lot of processing speed. Downside is that there is a minimum and maximum distance, based on the frequency, becuse you don’t necessarily know which wave is phasing if the distance involved could allow more than one wave to be in flight… but there are ways around that like pulse counters… I.E., the third pulse was the last one I sent in a burst, and the phase shift equalled “X”, so distance must be “Y”. From my reading this method was how the problem of radar distance ranging was solved in the 30′s.

  19. Rioexxo says:

    All of us/you ROCK!! What great thinking, plotting, analyzing! The speed of light seems to be relative….®

  20. Bob Spafford says:

    Well, actually the speed of light in the optical fiber is quite a bit less. The index of refraction of most glass is about 1.5 Therefore light is moving at 1/1.5 or 67% of the speed of light in a vacuum. Lenses focus light because in the thick part of the lens, the light spends more time at the reduced speed, therefore emerging from the lens at a later time than light from the thinner part, so the beam bends toward the slow (thick) side. Electrical pulses in a copper wire move at about half the speed of light, or about a foot a nanosecond. Even the atmosphere around us makes light slow to 99.97% of C. Even the dust in outer space slows light from distant super novas enough so that it arrives at earth several days later than the neutrinos from the event do. Turns out that it isn’t all that difficult to put the brakes on light. Or is that put the brake lights on?

  21. Mr. Wizard says:

    Time flies like the wind!
    Fruit flies like bananas!
    Are we clear?

  22. Actually, it should be quite easy just with one detector, one mirror; the laser and an Arduino running at 16MHz.

    Firstly you get the laser to generate PWM pulses of light controller by the Arduino. The frequency isn’t very important; something in the order of ms will be fine.

    You set a timer-capture unit so that it’s at its maximum supported frequency (8MHz on a 16MHz Arduino) and measure the period between when the pulse is sent and when it’s detected.

    You move the mirror to a distance so there’s at least 1 clock pulse between starting the laser and receiving the result. The mirror should be placed at the minimum distance where this is the case: Distance m0, resulting in p 8MHz clocks.

    You then move the mirror to the minimum distance where there’s p+1 8MHz clocks between sending a laser pulse and detecting it. This is distance m1.

    The speed of light is: (m1-m0)*0.5*8000000m/s.

    m1-m0 will ideally be 18.737m; a little shorter when measuring the speed of light in air; but still, a feasible experimental distance (m0 will add at least another 18.737m).

    On a 20MHz AVR-based computer, such as a FIGnition, this would be reduced to 15.5m: even more feasible :-)

    In either case, the upshot is that you don’t need nanosecond resolution, nor complex apparatus!

    -cheers from julz

    [Note: obviously I'm working in metric, m is in metres]

  23. Oops, the speed of light is (m1-m0)*2*8000000m/s :-)

    -cheers from julz

  24. Dave says:

    There are a couple of half-decent ways to measure very accurate time periods.

    The first is a cascaded row of logic gates (like an asynchronous shift register). Use the “start” pulse to send a signal into the first gate, that propagates through each gate in turn until the “stop” pulse comes along and disables the propagation. Count how many gates the signal made it down the line before it stopped, multiply by the propagation time of each gate and Bob’s your Uncle.

    Alternatively, the PIC24F series micros from Microchip have a CTMU module for this sort of thing. It’s basically a decent current source, a capacitor and an ADC, but it can theoretically interpolate between clock signals, turning a 16MHz clock into an effective clock speed of ~16GHz, or ~61 picoseconds per ADC level. Cool, huh!

  25. Wouter says:

    You could measure the time it takes for the time from the input of the arduino to go high until the signal is received again with two (very different) distances. That would negate the error from the delay of the electronics and laser. That is no solution yet for the low speed of the arduino though.

  26. Trolololo says:

    Quite easy to measure the speed of light using a good old analog oscilloscope. No fancy arduino needed. Just a repetive pulsegen with short risetime (HP 8082A) and a fast CRO (Tek 7904A)

  27. Dax says:

    The way it’s actually done, and was done without a MCU is to use a rotating mirror.

    You have a beam that bounces off a rotating mirror through a slit. A faraway mirror reflects the beam back through the same slit.

    The mirror has rotated in the time it took for the beam of light to return, so it now bounces off the rotating mirror at a different angle. Knowing the rotational speed of the mirror and the distance between the two mirrors, you can measure the speed of light from the angular displacement of the returned beam.

  28. The Steven says:

    It could make for a useful rangefinder. Hmmm…

  29. Ted Smiles says:

    The laser could be bounced off the reflectors on the moon, but at such a low power level, detecting what comes back (if anything) would be another problem.

    Large telescopes have high powered lasers they point at the moon.

  30. Tom the Brat says:

    Easy with a longer distance. Did it in college physics down the hallway of the “natural science” building.

    You need a bright flash, like a camera flash, 2 photocells and a mirror. Position 1 to see the flash, the other to see the reflection from the mirror way over there. Fire the flash and time the difference. Don’t forget to multiply the distance by 2.

    For our stone age experiment in the mid 70′s, we used a strobe and oscilloscope. The physics department’s scope wouldn’t trigger, so I ran over and got one from electronics that I knew worked.

    I believe it was once done with a lamp, a spinning wheel with vanes on it and a mirror in another village. He measured how much of the flash between the vanes he saw and given the rpm of his gizmo.

    I love the chocolate method, and like all proper mad scientists, she ate her experiment when finished.

  31. Willem says:

    Grass Valley take a slightly different approach instead of measuring the time difference between the pulse leaving the source and arriving at the sensor. Instead they emit a longer pulse, and turn off the sensor, then measure the amount of light captured in the photocell.

    This means that your not actually physically measuring the time difference. so long as you can turn on the sensor, emit a pulse, turn off sensor at an accurate interval its much simpler.

    Of course you’ll have to measure the reflectivity of the material you’re bouncing the light off too.

  32. khani3s says:

    I will wait for someone compile all ideias and implement a cheap rangefinder with an ARDUINO, of course.

  33. Could not you do something with constructive/deconstructive interferance paturns?

    Have a lazer beam split, have one go a longer distance then the other and bring them back together….then…umm..
    ok, forget it, I have no idea where I was going with this.

  34. natecaine says:

    No need to measure.

    By international convention the speed of light has been defined since 1983 to be 299,792,458 m/s.

  35. Skippy says:

    All you need to measure the speed of light is clear jello and a coherent light source. The angle of refraction through the Jello along with the index of refraction can be used (Snell’s Law) to calculate the speed of light.

    It’s more fun to deal with discrete timing, but at least this method also involves a laser!

  36. NATO says:

    This is stupid. No “arduino” has the necessary clock speed to make such a measurement. Why would you guys even post such a stupid write up.

  37. Kartman says:

    The Bosch rangefinders have been hacked. What cpu do they have in them? A Mega169. It uses the phase measurement technique. Another commercial rangefinder uses a mega128.

  38. blinkenlightblog says:

    If you like my experiments, please support me by voting for me at the buildounge laser cutter contest. It takes only one 1 minute of your time and 3 clicks. Just navigate to the page, click my entry (3rd from the top), scroll down and click the vote button.

    Just one additional comment for those that properly noticed that my setup is to slow for measuring the speed of light directly on short distances. This is the whole point of this experiment. I wanted to try out statistical resonance. Read the details and the referenced research paper for the details.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s