Proyecto final de semestre: Se desarrollo un vehículo que recibe comandos por el puerto serial y realiza las siguientes funciones según el comando sea el comando recibido: - Genera distintos tonos por un buzzer. - Controla el movimiento de un carro (con 2 motores) con comandos - Controla el movimiento de un carro (con 2 motores) con Joystick. - Lee y envía el color leido por el puerto serial al PC - Muestra los colores leídos por una pantalla FFT instalada en el vehículo.

Dependencies:   mbed UniGraphic

Committer:
CCastrop1012
Date:
Fri Sep 03 05:26:27 2021 +0000
Revision:
0:3a420fc22672
Proyecto de final de semestre, finalizado y funcional.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
CCastrop1012 0:3a420fc22672 1 #ifndef SCOLOR_TCS3200_H
CCastrop1012 0:3a420fc22672 2 #define SCOLOR_TCS3200_H
CCastrop1012 0:3a420fc22672 3 #include "mbed.h"
CCastrop1012 0:3a420fc22672 4 /* **************************************************************************
CCastrop1012 0:3a420fc22672 5
CCastrop1012 0:3a420fc22672 6 @fabeltranm 2019
CCastrop1012 0:3a420fc22672 7 fbeltranm@ecci.edu.co
CCastrop1012 0:3a420fc22672 8
CCastrop1012 0:3a420fc22672 9
CCastrop1012 0:3a420fc22672 10 datasheet https://www.mouser.com/catalog/specsheets/TCS3200-E11.pdf
CCastrop1012 0:3a420fc22672 11
CCastrop1012 0:3a420fc22672 12
CCastrop1012 0:3a420fc22672 13 S0 Frequency scaling
CCastrop1012 0:3a420fc22672 14 S1 Frequency scaling
CCastrop1012 0:3a420fc22672 15 S2 Photo diode selection
CCastrop1012 0:3a420fc22672 16 S3 Photo diode selection
CCastrop1012 0:3a420fc22672 17 OutFreq Frequency
CCastrop1012 0:3a420fc22672 18
CCastrop1012 0:3a420fc22672 19 -----------------------------------
CCastrop1012 0:3a420fc22672 20 | ____________ ____________ |
CCastrop1012 0:3a420fc22672 21 ----> | | | | | | ___ ___
CCastrop1012 0:3a420fc22672 22 Light | | Photodiode | | Current |--|---OUTPUT_FREQ | |___| |___
CCastrop1012 0:3a420fc22672 23 ----> | | Array |---| to | |
CCastrop1012 0:3a420fc22672 24 | | | | Frequency | |
CCastrop1012 0:3a420fc22672 25 | |____________| |____________| |
CCastrop1012 0:3a420fc22672 26 | ^ ^ ^ ^ |
CCastrop1012 0:3a420fc22672 27 -------|--|-------------|--|-------
CCastrop1012 0:3a420fc22672 28 | | | |
CCastrop1012 0:3a420fc22672 29 S2 S3 S0 S1
CCastrop1012 0:3a420fc22672 30
CCastrop1012 0:3a420fc22672 31 SO | S1 | OUTPUT FREQUENCY SCALING | | S2 | S3 | PHOTODIODE TYPE |
CCastrop1012 0:3a420fc22672 32 0 | 0 | power down | | 0 | 0 | Red |
CCastrop1012 0:3a420fc22672 33 0 | 1 | 2% | | 0 | 1 | Blue |
CCastrop1012 0:3a420fc22672 34 1 | 0 | 20% | | 1 | 0 | Clear (no filter) |
CCastrop1012 0:3a420fc22672 35 1 | 1 | 100% | | 1 | 1 | Green |
CCastrop1012 0:3a420fc22672 36
CCastrop1012 0:3a420fc22672 37 ******************************************************************************/
CCastrop1012 0:3a420fc22672 38
CCastrop1012 0:3a420fc22672 39
CCastrop1012 0:3a420fc22672 40 #define SCALE_100 1
CCastrop1012 0:3a420fc22672 41 #define SCALE_20 2
CCastrop1012 0:3a420fc22672 42 #define SCALE_2 3
CCastrop1012 0:3a420fc22672 43 #define POWER_DOWN 4
CCastrop1012 0:3a420fc22672 44
CCastrop1012 0:3a420fc22672 45 class scolor_TCS3200 {
CCastrop1012 0:3a420fc22672 46 public:
CCastrop1012 0:3a420fc22672 47 scolor_TCS3200(PinName s0, PinName s1, PinName s2, PinName s3, PinName s_in);
CCastrop1012 0:3a420fc22672 48 long ReadRed(); // retorno el tiempo en alto de OutFreq para Rojo en ns
CCastrop1012 0:3a420fc22672 49 long ReadGreen(); // retorno el tiempo en alto de OutFreq para verde en ns
CCastrop1012 0:3a420fc22672 50 long ReadBlue(); // retorno el tiempo en alto de OutFreq color azul en ns
CCastrop1012 0:3a420fc22672 51 long ReadClear(); // retorno el tiempo en alto de OutFreq sin filtro en ns
CCastrop1012 0:3a420fc22672 52 void SetMode(uint8_t mode);
CCastrop1012 0:3a420fc22672 53 private:
CCastrop1012 0:3a420fc22672 54 DigitalOut _s0;
CCastrop1012 0:3a420fc22672 55 DigitalOut _s1;
CCastrop1012 0:3a420fc22672 56 DigitalOut _s2;
CCastrop1012 0:3a420fc22672 57 DigitalOut _s3;
CCastrop1012 0:3a420fc22672 58 DigitalIn _s_in;
CCastrop1012 0:3a420fc22672 59 Timer timer;
CCastrop1012 0:3a420fc22672 60 long pulsewidth();
CCastrop1012 0:3a420fc22672 61
CCastrop1012 0:3a420fc22672 62 };
CCastrop1012 0:3a420fc22672 63 #endif