Al's Robotics....



Site Index
Site Index

Robotics Shop

Rambo Auto Tools

Robux Project





Robotics Events


My Robots

Linux Computing
Reading Books

PIC Micro


Latest News

new information added to the Robux Project Pages click here for more info


The LM339 Comparator IC

The LM339 comparator is a 14 pin chip that has 4 comparators built into to it, it can be used to do lots of things inside a robot like comparing 2 voltages, following a light, following sound or even heat the list is endless. The way the comparator works is by having an input voltage and a reference voltage, the reference voltage is what determines when the comparator turns on or off it's output.

So lets say we want to know when the voltage in are robot exceeds 5 Volts (V), we would set the reference voltage at 5V or just below and connect the input to the power source that is to be monitored, then when the input voltage exceeds that 5 Vs it will trigger the comparator which could have an LED hooked up to it to give us a visual indicator.

Night lighter

This circuit would be good for a BEAM robot. Now for a practical task using the LM339 comparator, we will make a light sensor that tells us when its dark by lighting an LED. Now to do this we are going to do a trick with the comparator and swap it's reference voltage and input voltage over in order to invert the output. If it was the other way around then the LED would be on in the light instead of in the dark.

Parts to used:

  • 1x LM339 IC = LM339
  • 1x LED (small) = D1
  • 1x 4.7K preset pot = R4
  • 2x 220R resistors = R1 & R2
  • 1x 470R resistor = R3
  • 1x LDR (light dependent resistor) = LDR

This circuit will be designed to work at around 5V but the LM339 comparator can work from 2 to 18 Vs

If your building this circuit for the first time it's best to build it on a bread board so you can fix any mistakes you make quickly and easily.


Above is the circuit for this project, it's nice and simple as it's only got 7 components in it to make it work.

Once your circuit is up and running you can begin to change the light sensitivity by turning the 4.7K preset. This will change the amount of darkness needed to turn the LED on.


Other uses

This circuit could be used with almost any type of resistive sensors, so you could try replacing the LDR with a heat sensor so your robot would know when it's getting too hot. And you could have 2 of these circuits and have them linked up so your robot can follow light, heat or sound.








Web pages built and by A R Martin E-mail at:


Home-page Robots Tutorials Links E-mail Circuits Events BEAM PIC Microchip Robotics Shop Computers FMM-RobotWars Sponsors Suggested reading Ebay Listings Serial Speed Controllers MicroMouse Walkers Driller-Killer Laptops Excaliber Robot Retox Drill Robot Robot motors Robot Builder Google Robux Project gorobotics Robot Cafe Robotics Solar Navigator PIC Axe Tech Supplies MUTR GSM Control Home Automation RC tracker Qtronics Design - Electronics & Firmware Design Artist R C Martin

HP 7210 Right Cartridge Error