Let's Make Robots!

DIY compass module

Hi A few days ago an idea in my mind to make a simple and cheap compass (module). I made a gradient ring in photoshop (see atachments). The idea is that i will stick this ring on a normal compass so that it rotates with the compass. After that an ir phototransistor will be fixed over this ring and will be mounted on the main compass frame which doesn' rotate with the compass. This phototransistor will be connected to a transistor or some other circuit (which i haven't thought of yet) which will amplify the phototransistor's voltage and send it to a picaxe's analog input pin. So as the compass will rotate, the analog voltage will change and the picaxe or maybe some other microcontroller will know the change. Also i am confused about using a ldr instead of an ir led. Is

Untitled-1.jpg20.21 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

The Led is the light generating device and the LDR is the light sensing device.

You cannot choose one instead of the other.

The problem is the dynamic range of the couple light generation/light sensors.

Imagine you use a very, very strong LED. Your sensor will be blind and you will detect variation only on the darkest places of your ring. The light gray parts will all seem the same to the sensor. Your lignt generation must be adapted to your sensor to get the most out of its dynamic range and avoid sensor saturation or underactivation.

So power is an important factor and there is no rule. You will have to experiment by adding a variable resistor in serie with your LED and check the values returned back by your sensor.

Another factor is wavelength, for the emitter (LED) , the reflector (paper) and the sensor. LDR (AFAIK) react more to visible light and UV. Phototransistor is more sensitive in IR. So, if you use IR, use a phototransistor with it, not a LDR. If you use green, blue of UV LED, maybe an LDR will be more efficient (note the maybe and the AFAIK...). I think that paper will reflect UV better than IR as there are some highlighting agents to make it whiter.


By the IR LED i meant IR phototransistor. I am planning to enclose the whole appratus in a small box so that i don't have to worry about the changing light conditions all the time. And i think a single white led (low power) with a variable resistor and a LDR will do.

There have been numerous construction articles over the years using the very inexpensive hall effect device as a compass. That way it would be much smaller, immune to ambient light, and with no mechanical parts.

I would go with holes in that ring paper. every 2-4 degrees or so to get a decent value out. This requires a light barrier to shoot through the holes. The problem with that "real" compass is that it has to be exactly leveled horizontally.


Digital compasses still have to be horizontal or else thay will give bad readings.