STEP TWELVE: Sumo Comparator

Overview

In this lesson, you will learn how to use a comparator to control your sensor. This is method provides the most accurate results and allows you to adjust easily for changes in ambient light or changes in the surface you are detecting. It also allows you to use interrupts in your code. The downside is that it requires a more complex circuit.

Exercise

  1. Refer to the section on comparator.

  2. Construct this exact circuit including the LED, but connect the output of your line sensor to Vi instead of the light sensor and resistor shown in the circuit.

  3. Connect Vo to a digital pin on your microcontroller board.

  4. Write a program that prints “white” when the sensor is over a white surface and “black” when the sensor is over a black surface. Note that you can easily adjust the sensitivity of this circuit. You can also easily and visually see when the sensor detects a surface of either white or black.