Light Spectrometer From a "battery Powered" Head Inspection Lamp




About: Hi I like to have a go at anything that's interesting, from CNC to toy making, recently I have been dismantling an old Cybot to link to Arduino using Scratch for Arduino as the initial language. I have thre...

Hello if you like this please take the time to vote in the competitions


At the end of my light sensing instructable where I played with the measurement of reducing sun light levels as well as making it into a laser game , I mentioned that I wanted to have a go at making a full spectrometer. This instructable is a step closer.

In the instructable I said I wanted to add a diode array, unfortunately I have not been able to get hold of one, so this will be a scanning spectrometer.

Diode array spectrometers

These work generally by having no moving parts. The light passes through the sample and is split into its separate spectral components using a prism or similar device. The separate wavelengths then fall onto the detector where each absorbance value is measured at the same time.

Scanning spectrometers

These work slightly differently in that the light is first split by the prism, it the passes through a narrow slit which helps to reduce the number of wavelengths of light that can fall on the sensor after it has passed through the sample.

In this type of system there is a single detector that has to measure each value in turn and because of this the light splitting device has to rotate to direct the sequence of wavelengths onto the sample and so onto the detector.

The spectrometer in this guide will use a diffraction grating a hologram printed onto a price of glass, I got this from work (a spare from a service visit).

If you don't have access to a gratting, you can make one by cutting a piece of a DVD.

HOW Usefull is this instrument

The usefullness of this instrument is limited only by your imagination examples are as follows:

  1. Analysis of the light spectrum (measuring the amount and colour of available light
  2. Measurement of spectral reflectance transmitance and absorbance of materials
  3. Food colourants analysis
  4. Environmental analysis - pollution in water - its inexpensive and connect to a laptop and not a big issue if it gets field damaged
  5. Training tool (educational) A great way to get your children into progamming and developing imaginative solutions.

The above and many more would of course all require calibration of the equipment


Step 1: Parts List and Software


Variousjumper wires
TenLight Emitting Diodes
OneLight Dependent Resistor 10 K Ohm up to approximately 130 K Ohm

Batteries : The light source uses 'AAA' x 2 for the LED's you can also make the unit portable by powering the Arduino using a 9 volt battery and of course if you do go portable you will need a battery in the laptop you use to collect your data

Light source

The light source for the spectrometer is a battery powered head inspection lamp - I got a cheap one to canablise from the pound shop


The Arduino is an UNO, the LED's are low values and the Pot is one I had laying around.

The LDR is one salvaged from my Cybot which was modified in a previous guide see

I found a good site for calculating the values for resistors - see the first picture on this guide, the link to which is just below here. I used 33 ohm resistors - these where considerably smaller than my first attempt using some a rescued from an old alarm system - they where way too big leaving me wondering why nothing worked when I switched the "finished thing on"?.


There are two bits of software and one add on required for this project to work:

The Arduino IDE is free to download from the following location and comes as either an install of zip file - I like the Zip (easier to use and and be run from a flash drive for portability)

MICROSOFT EXCEL - unfortunately not free - I have office 2013 on a windows 7 computer

Finally the most important bit is the add on - this is for Excel and comes from a site called PRALAX

The file you want is PLX-DAQ and runs as a macro from inside Excel. This is a great little file as it can be used to monitor any serial port and gather the resultant data sent through it. All that is required is some specific lines of code in the Arduino sketch to tell it the send data to specific cells in Excel.

You also need to specify the port speed and ensure that the Arduino is set to the same speed - initially I tried 9600, but although this worked for the test spreadsheet that only sent text to excel from the Arduino, I needed to set it to 128000 for the final project as I would be monitoring the response times for the LED's dependent upon the resistance of the LDR at any given time.

Step 2: Why Black

Spectrometers work by taking measurements of light, either the transmittance or the absorbance. So allowing any additional light into the sensor while in use would adversely affect the results.

Painting everything black helps to eliminate reflection and reduce light

Step 3: Sample Holder

The sample holder is just that. When you are performing an analysis your sample solution is held in what is called a Cuvet, a glass container that is as optically pure as possible. This Cuvet is placed in the instrument in a holder that is in the path of the light coming from the diffraction grating.

For this instructable I have made one on the lathe. I started by turning one end which would later be held in the jaws on the lathe church, this would ensure that it was centered. Once flipped I drilled a hole in the end that would hold the Cuvet - see the third picture and went on to drill two holes one opposite the other at the square end of the piece. This would be the path through the sample for the light reaching the sensor.

As I wanted as much light to reach the sensor as possible I made one of the holes slightly larger. I tidied the piece up and cut a tenon just below where the bottom of the Cuvet sat in the central hole and parted it off once it had been rounded and smoothed.

None of the prices for this project need polish as they will all be painted black.

Once the paint was dry,inside and out I used a hot melt glue gun to secure the LDR sensor in place, this in turn was also painted as the glue itself is slight translucent. I had put a hole into the piece of MDF intended for the base and held the sample holder in place using a wooden washer and screw which would allow me to rotate the sample holder to improve alignment with the light beam.

Step 4: Slits

Once the light is split by the diffraction grating there is a need to limit the portion of the spectrum from hitting the sample at the same time. To do this you use a device called a slit and as it sounds this is just a very thing parallel gap in front of the sample holder.

For mine I hot glued two Stanley knife blades over an opening in a small panel that would be glued in front of the sample holder along with another piece to form a small "dark room" around the sample. This too was painted black.

Step 5: Defraction Gratting

The diffraction grating was mounted onto an R.C. servo and hot glued in front of the slit at a slight angle. The exact angle is not important as the software used later will control the direction of the grating.

You will see on the pictures that it cut a hole to take the servo, in the end the was not needed as I needed to lift the servo up so that the grating was in front of the slit and not below it. The hole was filled with hot met glue which also held the servo solid.

Step 6: Light Source

For the light source I started using a household torch, but found that the incandescent bulbs produced a very diffuse spectrum (pattern of split colour) once the light left the grating. So a quick visit to the local pound shop and I had one of those battery powered led lights that you strap to your head. It takes three AAA batteries.

To hold it again I turned to the lathe to make a hollow tube and support, which would be kept in place by another tenon through the base.

I had only intended to take one of the led lights from the torch, but when I took it apart found that just about the whole cluster fit into the tube and would only require a little shielding for the stray light

With all the parts made, or in place I used the hot melt glue to fix the sides in place and completed the box by painting it black.

Step 7: Making a Light Shield

Once I started collecting data(see the end of the guide) I decided the spectrometer needed additional light shielding.

Enter my wife's hobby - card making - I borrowed her scoring board to make creases in the cardboard used for the shield.

I have not included a template for this as its shape and size will depend upon your device dimensions. just to say that I used double sided sticking tape to hold the joints together and when I came to cutting the hole for the Cuvet I put the cover in place then pressed on the top to make an indentation for the hole I needed to make then a craft knife was used to make the cut.

Just a word of caution make sure you line up the slit carefully or you will block the source.

Step 8: Wiring Up the Arduino

Please see the images for the wire diagrams

You will note that I have given two options one includes a battery, a better way to power the system than relying on the USB power from a computer, although you will still need to attach the USB cable as it is needed to collect the live data as you carry out experiments.

Step 9: Arduino Code

The Parallax install file creates a couple of example spreadsheets which are really all you need on the Excel side. Once installed all you need do is open the example file and accept the use of macros- at which point the PLX DAQ control will open. Set it up as per the previous image in step 1 making sure that you select your com port and not the one I have used (unless yours happened to be COM 3 as well)


The attached code has been written to allow the Arduino to read the potential difference between. The potential value is firstly calibrated using the Potentiometer.

The calibration is done by completely covering the LDR so that its resistance drops to as close to nothing as possible (this makes the LEDS change very quickly) then you adjust the POT until the cycling light change from the LEDs is visible.

The more you adjust the POT the great you can make the time changes registered at Excel, but be careful not to go too far or you will not see data at the other end of the scale (i.e. when you expose the LDR to light again)

Step 10: Collecting the Data

I have tested the system a number of times (see the charts) the tests where performed on the following

  • Air with no obstruction
  • Through a cuvet
  • Through yellow dye
  • Through red dye
  • Through green dye
  • Through green dye, but adjusting the degrees of rotation to one per step

The additional chart is an enlargement of the red chart due to the scale of the data points.

You will note on the charts that there is a definite difference between the different sample types, you need to look at differences between the samples and the air blank, and then camp are thinks like missing steps in the charts or the ratios between the steps.

Look at the yellow dye chart as well as the enlarged red chart.

Also if you take a look at the Green dye chart where I reduced the angle of rotation per step to 1 degree, then you will see that its possible to get a lot more data as the number of steps increases quite a lot. Unfortunately with my current servo I was unable to go lower than 1 degree. I did try but the servo just sat there not moving, so at present until I get a small enough stepper motor my limit is 1 degree of rotation per step.

If you take a look at the three plotted charts at the end, of the green dye at 1 degree rotation/step you will see that for the most part they are quite uniform, except near to the end this was during the readings for the darker blue light from the diffraction grating - you can clearly see a step change (the last chart shows this the best).

Step 11: Improvments

This is a good basic spectrometer, however everything can be improved on and for this instructable I think this would be in the addition of adjustable slits to enable better discrimination between wavelengths, as well as some means of focusing the light from the LED's more accurately onto the gratting.

Thanks for looking and please don't forget to vote if you liked or found this interesting.

Battery Powered Contest

Second Prize in the
Battery Powered Contest



    • Woodworking Contest

      Woodworking Contest
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Gardening Contest

      Gardening Contest

    28 Discussions


    17 days ago

    Yes, I have worked with spectrometers in biotech they are worth 1000-1500 dollars US so the fact that you built this is very impressive. Nicely done.

    1 reply

    Question 1 year ago

    First... This is amazing! And it resembles very closely to the insides of an expensive spectrometer from a lab.

    I have a question. I've been searching for ir for a while now... I am trying to make a fixed wavelength spectrometer with a LED and a LDR. The simplest way to do so may be using a multimeter to read the LDR, for example, although I use an Arduíno interfaced with a software I made so I don't have to register all the values and make thousands of calculations... I can use it to calculate concentrations when comparing the absorbances of my samples with standards, of known concentrations. But, the molar extinction coefficients of the compounds I'm studying are not the same as I would get in a normal laboratory spectrometer (I have access to them, so I can even compare results with the same standards in the two equipments).

    I'm happy with the results but quite distressed about this molar extinction diferences. Can anyone help me or have any idea why this happens?

    Thank you! ;)

    1 answer

    Answer 1 year ago

    Hi thanks for liking my guide - Ive also built a dual beam instrument which splits the light source then uses one stream as a blank to help remove background signal. One problem with both is noisy baseline. This is due mostly to the fact that they are home made without the tolerance and control employed in factory made units like those from Perkin Elmer etc. even though the dual beam uses some high end parts the weight of the optical bench is still only that of a piece of MDF so vibration is an issue in producing noise, stray light will also be a problem.

    To get to your question I think the difference in lab to home builts units is down to the issues mentioned above. You will not be able to remove it mechanically. If you do have access to a lab unit try running your standards on that then very soon after on yours and try to calculate a correction factor from the two sets of readings and apply this to your samples to see if you can improve accuracy.

    Hope this helps Thanks again

    Heres the link to the dual beam unit


    2 years ago

    nice build, but what would be the distance and angle between each parts(like lamp, prism, sample).

    1 reply

    Reply 2 years ago

    Hi the servo is set so that the body is approx perpendicular to the sample ans slits - because the diffraction grating rotates the angle is not really an issue as you an adjust position in the programming.



    3 years ago

    Great build, lots of good ideas. I will do one of these (but not soon). A possible suggestion for the light sensor might be the scanner head out of a photocopier. (you find them in junk piles from time to time) These already have a slit, and multiple, high quality light sensors in them, creating a ready made sensor array.

    Thanks again for your great instructable.

    1 reply

    4 years ago on Introduction

    Hey! I really like your design and am planning to make it. I am doing a research on the impurities present in hard water in different areas in my town. I am planning to use this spectrometer to find out the impurities (from the wavelengths) and the concentrations of the ions. How can I do it using this instrument? You mentioned in the beginning of the instructable that this is possible. Please help me out here! Thanks!

    1 reply

    Reply 4 years ago on Introduction

    Hi thanks for the comments and will be create if you do make it. As for concentration analysis. Keep in mind that accuracy will depend upon the greating. You will need to know the type of contaminants you are looking for and will need to accurately make up standard solutions. Example say your looking for chloride make up a set of solutions at a range of concentrations. Run each on the instrument several times , pick a point on the traces and plot the average for each solution against concentration. Then measure you unknown and read off the concentration from the average reading and the chart. Keep in mind that you do not have a database of responses so will not be able to use this to identify only measure.

    Have fun and let us know how it goes


    4 years ago on Step 5

    Hi thanks for comment.I think that the type of motor is an important factor in accuracy of the selection of the part of the spectrum being directed to the sensor, however its dependant upon the the quality of the detector. At present its only an ldr so its sufficient to use the servo and take an average of the readings. I am still trying to identify a better quality sensor then I think it will be good to have the stepper, not only for accuracy, but also repeatability.

    Thanks again


    4 years ago on Step 5

    Hi sir.

    I love this project that you are doing. I am just curious about the precision of a servo motor. Wont a stepper motor work better for this part?

    bomb maker1

    4 years ago on Introduction

    can you please please please give me the exact values for the LDR and the POT. please. at least tell me in what range there values are. thx for the great project.

    5 replies
    HUKBMBEARbomb maker1

    Reply 4 years ago on Introduction

    Hi have had a look at the LDR there are no values to be seen, it was one left over from a cybot, but it is not of any great resistance - a low value one (cheap is best) one will do - the higher the resistance the less responsive the spectrometer will be

    bomb maker1HUKBMBEAR

    Reply 4 years ago on Introduction

    thx, really helpful. But can you at least tell me in what range the LDRs resistance is? Like from Xohms to Y ohm. Or at least tell me if its in the range of kiloohm or ohm. Really really helpful tanks for the great project

    HUKBMBEARbomb maker1

    Reply 4 years ago on Introduction

    Hi back from holidays now and have had a chance to put a meter on the LDR if I am reading correctly the LDR goes from 10 K Ohm to 130 K Ohm approximate readings only as you will get a bit of variation depending on the light levels you measure in.


    Reply 4 years ago on Introduction

    Just an additional comment - its the POT that will give you the range as it adjusts the overall resistance of the LDR and so the speed of the signal measured, You could try other detectors e.g. the sensor from a TV remote - Try it as is then try cutting the crystal bulb off an see if it changes sensitivity.

    HUKBMBEARbomb maker1

    Reply 4 years ago on Introduction

    Hi will take a look and post info shortly - just back from holiday so a bit of a mess at present.

    Just looked at pot - LIN 220 Kohm let you know the LDR shortly


    4 years ago on Introduction

    Only one question...Could/should a prism be put on the motor insted? Would it be easier to regulate the wavelengths?

    Very nice instructable. One of the best i've seen. I'm considering building one like yours.

    1 reply

    Reply 4 years ago on Introduction

    Hi I tried to reply last night but the message did not send for some reason.

    A Prism will work, but depending on quality /size etc you will only get a narrow split of the spectrum, in this case you could try to narrow the slit gap to be more selective on which part to the spectrum you are sampling at any one time.

    Alternatively do a search for CD spectroscope - you can use a good quality CD/dvd and cut a section out - mount that on the motor it should work fine (listed in the instructable).

    here's a link that might help:

    The grating I used was a part replace during the service of a piece of lab equipment, if you want one like that you could try to email the service department at Perkin Elmer or possibly Schimadzu and ask if they have any old parts - they are of no further use in a laboratory environment once swapped out during a service and are usually just binned.

    Hope this helps