Introduction

This time we reinvented the line-tracking sensor. Beyond recognizing two specific colors or output through digital or analog only, the Smart Gray Sensor has integrated both digital and analog output features.

In digital mode, the user can have two color data records through simple button operations. To achieve two-color detections you simply need to monitor high and low outputs, and therefore requires no more configuration after being set up. In analog mode, the output value reacts precisely to the color grayscale detected.

Apart from being a stable and adaptative sensor in various environments, the Smart Grayscale Sensor also demonstrates a great potential in low-cost projects of color, grayscale and adjacence lights.

Specifications

Tools need

Change the sensor between Analog and Digital

Just short click the button and the mode will be changed between analog and digital.

Analog mode

Grayscale Sensor Connection Diagram in analog mode

In analog mode, the brighter the Sensor detects, the brighter LED will be. You can connect the sensor to analog pin to read the Grayscale from the sensor, just as the normal grayscale sensor.

Code Example:

int grayscalePin=0;
void setup()
{
 Serial.begin(9600);
 Serial.println("Smart Grayscale sensor:");
}
void loop()
{
  Serial.print("Grayscale:");
  Serial.println(analogRead(grayscalePin));
  delay(500);
}

Digital mode

In digital mode, you can set the logic of two different color by your own.

1. Long click the button until the LED slow blinking (which means first color detecting ready).

2. Let the grayscale sensor face to the first color (such as white paper)

3. Meanwhile short click the button and the LED gets dark (which means first color detected).

4. Short click the button and make the LED fast blink (which means second color detecting ready).

5. Let the grayscale sensor face to the second color (such as black paper)

6. Meanwhile short click the button and the LED gets dark (which means second color detected).

7. The first color (such as white paper) will be Logical '1', and the LED becomes bright.

8. The second color (such as black paper) will be Logical '0', and the LED becomes dark.

9. This setting maintains even if the power is off, so for one purpose, one setting is enough.

LED gets dark when facing the black paper

LED gets bright when facing the white paper

Grayscale Sensor Connection Diagram in digital mode

Code Example:

int grayscalePin=8;
void setup()
{
 Serial.begin(9600);
 pinMode(grayscalePin,INPUT);
 Serial.println("Smart Grayscale sensor:");
}
void loop()
{
  Serial.print("Grayscale:");
  if(digitalRead(grayscalePin))
  {
    Serial.println("White detected");
  }
  else
  {
    Serial.println("Black detected");
  }

  delay(500);
}

DFshopping_car1.png Get Gravity: Smart Grayscale Sensor from DFRobot Store or DFRobot Distributor.

Turn to the Top

category: Product_Manual category: SER_Series category: Sensors <!--Hidden Categories--!> category: Source category: DFRobot-->