Class library for a TCS3200 Color Sensor Module.
Dependents: LCD PROJETO PROJETO_MECATRONICO Bottle_Tracker_Insper ... more
TCS3200 Class Reference
Class library for a TCS3200 Color Sensor Module. More...
#include <TCS3200.h>
Public Member Functions | |
TCS3200 (PinName S0, PinName S1, PinName S2, PinName S3, PinName OUT) | |
Create a TCS3200 object connected to the specified pins. | |
long | ReadRed () |
Reads the output signal's HIGH pulse for RED. | |
long | ReadGreen () |
Reads the output signal's HIGH pulse for GREEN. | |
long | ReadBlue () |
Reads the output signal's HIGH pulse for BLUE. | |
long | ReadClear () |
Reads the output signal's HIGH pulse for CLEAR. | |
void | SetMode (TCS3200Mode mode) |
Sets the mode of operation. |
Detailed Description
Class library for a TCS3200 Color Sensor Module.
Example:
#include "mbed.h" #include "TCS3200.h" TCS3200 color(PD_8, PD_9, PD_10, PD_11, PA_1); //Create a TCS3200 object // S0 S1 S2 S3 OUT int main() { long red, green, blue, clear; //Set the scaling factor to 100% color.SetMode(TCS3200::SCALE_100); while(1){ //Read the HIGH pulse width in nS for each color. //The lower the value, the more of that color is detected red = color.ReadRed(); green = color.ReadGreen(); blue = color.ReadBlue(); clear = color.ReadClear(); printf("RED: %10d GREEN: %10d BLUE: %10d CLEAR: %10d ", red, green, blue, clear); wait(0.1); } }
Definition at line 62 of file TCS3200.h.
Constructor & Destructor Documentation
TCS3200 | ( | PinName | S0, |
PinName | S1, | ||
PinName | S2, | ||
PinName | S3, | ||
PinName | OUT | ||
) |
Create a TCS3200 object connected to the specified pins.
- Parameters:
-
S0 Frequency scaling output pin S0 S1 Frequency scaling output pin S1 S2 Photo diode selection output pin S2 S3 Photo diode selection output pin S3 OUT Frequency input pin
Definition at line 5 of file TCS3200.cpp.
Member Function Documentation
long ReadBlue | ( | ) |
Reads the output signal's HIGH pulse for BLUE.
- Parameters:
-
None
- Returns:
- Duration as nanoseconds (ns).
Definition at line 27 of file TCS3200.cpp.
long ReadClear | ( | ) |
Reads the output signal's HIGH pulse for CLEAR.
- Parameters:
-
None
- Returns:
- Duration as nanoseconds (ns).
Definition at line 34 of file TCS3200.cpp.
long ReadGreen | ( | ) |
Reads the output signal's HIGH pulse for GREEN.
- Parameters:
-
None
- Returns:
- Duration as nanoseconds (ns).
Definition at line 20 of file TCS3200.cpp.
long ReadRed | ( | ) |
Reads the output signal's HIGH pulse for RED.
- Parameters:
-
None
- Returns:
- Duration as nanoseconds (ns).
Definition at line 13 of file TCS3200.cpp.
void SetMode | ( | TCS3200Mode | mode ) |
Sets the mode of operation.
- Parameters:
-
mode POWERDOWN, SCALE_2 (2% scaling), SCALE_20 (20% scaling), SCALE_100 (100% scaling).
- Returns:
- None
Definition at line 41 of file TCS3200.cpp.
Generated on Sun Jul 17 2022 19:57:11 by 1.7.2