sensor de color prueba 1

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers scolor_TCS3200.h Source File

scolor_TCS3200.h

00001 #ifndef SCOLOR_TCS3200_H
00002 #define SCOLOR_TCS3200_H
00003 #include "mbed.h"
00004  /* **************************************************************************
00005  
00006 @fabeltranm 2019
00007 fbeltranm@ecci.edu.co
00008 
00009 
00010    datasheet https://www.mouser.com/catalog/specsheets/TCS3200-E11.pdf
00011 
00012 
00013     S0      Frequency scaling 
00014     S1      Frequency scaling 
00015     S2      Photo diode selection 
00016     S3      Photo diode selection 
00017     OutFreq Frequency
00018 
00019        -----------------------------------
00020       |   ____________     ____________   |
00021 ----> |  |            |   |            |  |                ___     ___ 
00022 Light |  | Photodiode |   |   Current  |--|---OUTPUT_FREQ |   |___|   |___
00023 ----> |  |   Array    |---|     to     |  |
00024       |  |            |   |  Frequency |  |
00025       |  |____________|   |____________|  |
00026       |       ^  ^             ^  ^       |
00027        -------|--|-------------|--|-------
00028               |  |             |  |
00029              S2 S3            S0  S1
00030              
00031 SO | S1 | OUTPUT FREQUENCY SCALING |        | S2 | S3 |   PHOTODIODE TYPE   |
00032  0 | 0  |        power down        |        |  0 | 0  |         Red         |
00033  0 | 1  |           2%             |        |  0 | 1  |         Blue        |
00034  1 | 0  |           20%            |        |  1 | 0  |  Clear (no filter)  |
00035  1 | 1  |           100%           |        |  1 | 1  |         Green       | 
00036              
00037 ******************************************************************************/
00038 
00039 
00040 #define SCALE_100   1
00041 #define SCALE_20    2
00042 #define SCALE_2     3    
00043 #define POWER_DOWN  4
00044 
00045 class scolor_TCS3200 {
00046   public:
00047     scolor_TCS3200(PinName s0, PinName s1, PinName s2, PinName s3, PinName s_in);
00048     long ReadRed();     // retorno el tiempo en alto de OutFreq para Rojo en ns
00049     long ReadGreen();   // retorno el tiempo en alto de OutFreq para verde en ns
00050     long ReadBlue();    // retorno el tiempo en alto de OutFreq color azul en ns
00051     long ReadClear();   // retorno el tiempo en alto de OutFreq sin filtro en ns
00052     void SetMode(uint8_t mode);
00053   private:
00054     DigitalOut _s0;
00055     DigitalOut _s1;
00056     DigitalOut _s2;
00057     DigitalOut _s3;
00058     DigitalIn _s_in;
00059     Timer timer;
00060     long pulsewidth();
00061 
00062 };
00063 #endif