Page 10 - Manual Técnico Proyecto_Float
P. 10
9. Códigos
Código que envía la señal
A continuación se detalla el código que envía la señal por medio de comunicación infrarrojo que
facilita el recibir y transmitir los códigos así como enviar mensajes entre las placas Circuit
Playground Express utilizando el sensor color, este detecta el color y envía las instrucciones para que
se active el panel donde están los pictogramas encendiendo las luces y los sonidos.
#include <Adafruit_TCS34725.h> // se incluyen las librerías
#include <Adafruit_CircuitPlayground.h>
#include <ColorTools.h>
#define IR_PROTOCOL NECX // define los valores asociados a los colores a detectar
#define IR_BITS 32
#define IR_CELESTE 0xE0E01F00F
#define IR_VERDE 0xE0E020BF
#define IR_FUCSIA 0xE0E030BF
#define IR_ROJO 0xE0E040BF
#define IR_MORADO 0xE0E050BF
#define IR_AMARILLO 0xE0E060BF
#define IR_AZUL 0xE0E070BF
#define IR_ANARANJADO 0xE0E080BF
#define ESPERA 3
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);
HSV hsv;
RGB rgb;
uint16_t clear, red, green, blue;
void setup() { // inicia ciclo principal
CircuitPlayground.begin();
Serial.begin(9600);
if (!tcs.begin()) Serial.println(F("Sensor error, check connection."));
tcs.setInterrupt(false); //Encender luz del sensor.
}
void loop() { // prepara sensor para detectar colores
tcs.getRawData(&red, &green, &blue, &clear);
uint32_t sum = clear;
rgb.r = ((float)red / sum) * 255;