Introduction: Light Spectrometer From a "battery Powered" Head Inspection Lamp

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.


FahadI8 made it! (author)2017-01-27

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

HUKBMBEAR made it! (author)HUKBMBEAR2017-01-28

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.


Bverysharp made it! (author)2016-03-17

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.

HUKBMBEAR made it! (author)HUKBMBEAR2016-03-18

Thanks for the comments glad you enjoyed the instructable - I will take a look at the sensors you suggested when I have a chance - good idea.

As you liked this one you might also enjoy my other on spectrometers for a dual beam model at

Cheers again

RaahishK made it! (author)2015-01-05

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!

HUKBMBEAR made it! (author)HUKBMBEAR2015-01-05

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

HUKBMBEAR made it! (author)2014-10-10

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

MartinStrydom made it! (author)2014-10-09

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 made it! (author)2014-08-14

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.

HUKBMBEAR made it! (author)HUKBMBEAR2014-08-16

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 maker1 made it! (author)bomb maker12014-08-18

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

HUKBMBEAR made it! (author)HUKBMBEAR2014-08-23

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.

HUKBMBEAR made it! (author)HUKBMBEAR2014-08-16

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.

HUKBMBEAR made it! (author)HUKBMBEAR2014-08-16

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

CrtSuznik made it! (author)2014-07-28

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.

HUKBMBEAR made it! (author)HUKBMBEAR2014-07-29

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

Sibeiko made it! (author)2014-07-07

As a fellow scientist, I've got to hand it to you, this seems really well thought out and made - I've seen lab equipment comparable to this (though arguably more expensive!).

I am curious though, I saw where you were working with different light sources. I'm willing to be the household incandescent gave issues due to it's size (the whole point source thing and all). I am wondering if you compared the 'empty' runs (no and/or empty cuvet) to a blackbody curve - this could help with looking at other materials, as well as other light sources (such as LEDs). Unless your headlamp was using those nice fancy white leds, in which case I'd be willing to bet that one of the older flashlight incandescents (or a non-LED uncolored Christmas light bulb) would give some good relatively unbiased runs that you could subtract out with said bb curve. In any case, I'd guess that this'd be something I think many readers here would also be interested in.

Again, I've got to say, pretty nice setup - I'm impressed!

HUKBMBEAR made it! (author)HUKBMBEAR2014-07-07

Thanks for the great suggestions on comparison /subtraction. Yes I did try incandescent - but for the size of body I could not at the time finds a suitable lamp. The light sight source used is the LED sort - the head lamp had a cluster of 6 which I was able to fit inside the turned tube to help direct the light and shield the detector fro direct light.

I think the secret will be to get better signal to noise ratio which you can see when I reduced the rotation speed- this gave the detector a fighting chance to take a reading. If I can add to this better slits the readings will be more specific to the wavelength being transmitted - I have a couple of vernier gauges that I will be trying to make a set of adjustable slits to test this at differing settings.

I think that once I can doe this it will make testing different light sources more meaningful and allow for better calibration of the setup.

Its been nice to talk - but have to go now - thanks again for the comments and if anyone else has suggestions please add them on to the responses.

Naren_Murali made it! (author)2014-06-25

great instructable rare to see elec tonics and physics in instructables

HUKBMBEAR made it! (author)HUKBMBEAR2014-06-26

Thanks I work a bit with Lab equipment and from an interest created the light sensor and arduino combination that developed into this one. I hope to take it a bit further and use a diode array to get better descrimination and signal strength.

Thanks again glad you liked

Umamaheswari Anandane made it! (author)2014-05-29

Sounds Interesting and well written !

HUKBMBEAR made it! (author)HUKBMBEAR2014-05-29

Thank you glad you liked it

craftclarity made it! (author)2014-05-27

Wow, heckuva build....!

HUKBMBEAR made it! (author)HUKBMBEAR2014-05-28

Thanks, it is an interesting one and I had fun making it. I think the hardest part was getting the software to run the servo without interrupting the operation of the led timers. Thanks for your comment. If you like this did you have a look at the other light sensor that this started from.

About This Instructable




Bio: 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 ... More »
More by HUKBMBEAR:Easy PlantingPouring WoodNine Men's Morris
Add instructable to: