The DFRobot Grayscale Sensor is an analog sensor. It is a special sensor with arduino expansion boards. The Gray-scale sensor interface uses PH 2.0 socket. The power supply needs the same controller, typically for 3.3V or 5V.


Note: the product is NOT waterproof and dustproof; the detection accuracy will be affected by the light brightness of the environment and light reflectance of the material the sensor detects.

Pin Definition

The definition of gray-scale sensor pin is

  1. Signal Output
  2. GND
  3. Power

Analog Sensor Pin Definition

Connection Diagram

Analog sensor connection diagram

Sample Code

void setup()
  Serial.begin(9600); // open serial port, set the baud rate to 9600 bps
void loop()
      int val;
      val=analogRead(0);   //connect grayscale sensor to Analog 0
      Serial.println(val,DEC);//print the value to serial

More Documents

DFshopping_car1.png Get DFRobot Grayscale Sensor (SKU:DFR0022) from DFRobot Store or DFRobot Distributor.

Turn to the Top