How to transpose my code to extension builder


#1

Hello

I’m having trouble adapting my code to make it an extension, my code works fine by uploading it to my Arduino board, but I can’t transpose it into extension builder
the sensor is a grove color v2 on arduino uno, i just want to send the color to a screen for example
my code:
#include <ColorConverterLib.h>
#include <Wire.h>
#include “Adafruit_TCS34725.h”

Adafruit_TCS34725 tcs = Adafruit_TCS34725 (TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_1X);

void setup ()
{
Serial.begin (9600);

if (! tcs.begin ())
{
Serial.println (“TCS34725 error”);
while (1) delay (1000);
}
}

void loop ()
{
uint16_t clear, red, green, blue;

tcs.setInterrupt (false);
delay (60);
tcs.getRawData (& red, & green, & blue, & clear);
tcs.setInterrupt (true);

// Take a relative RGB measurement
uint32_t sum = clear;
float r, g, b;
r = red; r / = sum;
g = green; g / = sum;
b = blue; b / = sum;

// Scale RGB to bytes
r * = 256; g * = 256; b * = 256;

// Convert to hue, saturation, value
double hue, saturation, value;

ColorConverter :: RgbToHsv (static_cast <uint8_t> ®, static_cast <uint8_t> (g), static_cast <uint8_t> (b), hue, saturation, value);
// Display the name of the color
printColorName (hue * 320);

delay (1000);
}

void printColorName (double hue)
{
if (hue <15)
{
Serial.println (“Red”);
}
else if (hue <45)
{
Serial.println (“Orange”);
}
else if (hue <90)
{
Serial.println (“Yellow”);
}
else if (hue <150)
{
Serial.println (“Green”);
}
else if (hue <210)
{
Serial.println (“Blue”);
}
else if (hue <270)
{
Serial.println (“Blue”);
}
else if (hue <330)
{
Serial.println (“Red”);
}
else
{
Serial.println (“unknown”);
}
}

how to simply transpose my code