Smart_Grayscale_sensor_SKU_SER0147 - jimaobian/DFRobotWiki GitHub Wiki
Introduction
Specifications
Tools need
- Smart Grayscale sensor V1.0
- Arduino controller
Change the sensor between Analog and Digital
Just short click the button and the mode will be changed between analog and digital.
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 colour by your own.
-
Long click the button until the LED slow blinking (which means first color detecting ready).
-
Let the grayscale sensor face to the first color (such as white paper)
-
Meanwhile short click the button and the LED gets dark (which means first color detected).
-
Short click the button and make the LED fast blink (which means second color detecting ready).
-
Let the grayscale sensor face to the second color (such as black paper)
-
Meanwhile short click the button and the LED gets dark (which means second color detected).
-
The first color (such as white paper) will be Logical '1', and the LED becomes bright.
-
The second color (such as black paper) will be Logical '0', and the LED becomes dark.
-
This setting maintains even if the power is off, so for one purpose, one setting is enough.
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);
}
Documents
- [..... Datasheet]
shopping [...... smart Grayscale sensor_SKU:SER0147] category: Product_Manual category: SER_Series category: Sensors category: Source category: DFRobot