Error in Coding

HI I am Burncore and I am little experience in the sensors area of arduino.
I got a Gy-31 color sensor and a arduino one board, the proyect i am doing is the “Robot Chamaleon” by MarkusB. here is the website:

/*  Robot Chameleon based on TCS3200 COLOR SENSOR and RGB LED
    Author: Markus Bindhammer
    Date: 2-6-2014
//**************************************** LIBRARIES ***************************************
#include <Average.h> // See

//************************************ GLOBAL VARIABLES ************************************

int OUT=2,S2=3,S3=4,LED=5,S0=6,S1=7; // define TCS3200 pins
int redPin=11,greenPin=10,bluePin=9; // define RGB LED pins

void setup() {

void loop() {

//************************************ FUNCTIONS RGB LED *********************************** 
void RGB_LED_Setup() {
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
void setColor(int red, int green, int blue) {
analogWrite(redPin, 255-red);
analogWrite(greenPin, 255-green);
analogWrite(bluePin, 255-blue);

//********************************* FUNCTIONS COLOR SENSOR ********************************* 
void TCS3200_Setup() {
void TCS3200_On() {
  digitalWrite(LED,HIGH); // Switch LED on
  digitalWrite(S0,HIGH); //Output frequency scaling (100%)
void TCS3200_Off() {
  digitalWrite(LED,LOW); // Switch LED off
  digitalWrite(S0,LOW); //Power off sensor
void NoFilter() { //Select no filter
void RedFilter() { //Select red filter
void GreenFilter() { //Select green filter
void BlueFilter() { //Select blue filter
void GetColor() { //0=white, 1=orange, 2=yellow, 3=red, 4=green, 5=blue, 6=object out of range
  float FrequencyClear,FrequencyRed,FrequencyGreen,FrequencyBlue;
  int PercentageRed,PercentageGreen,PercentageBlue;
  FrequencyClear=500.0/pulseIn(OUT,LOW,10000); // Frequency in kHz
  FrequencyRed=500.0/pulseIn(OUT,LOW,10000); // Frequency in kHz
  FrequencyGreen=500.0/pulseIn(OUT,LOW,10000); // Frequency in kHz
  FrequencyBlue=500.0/pulseIn(OUT,LOW,10000); // Frequency in kHz
  //Output frequency blue, green, red percentage represents the ratio of the 
  //respective color to the Clear channel absolute value:
  //Learned blue, green, red percentage values of different colors
  int SavedColorRed[] = {28,55,42,50,19,13}; 
  int SavedColorGreen[] = {30,25,36,22,45,26};
  int SavedColorBlue[] = {45,20,20,30,36,58};
  int ColorArray[3];
  int i_color; 
  int ClosestColor;
  int MaxDiff;
  int MinDiff=300;
  if(FrequencyClear<1.5)ClosestColor=6; // Object out of range
  else {
    for (i_color=0; i_color<6; i_color++) { //Find closest color
      if (MaxDiff<MinDiff) {
   } if(ClosestColor==0) setColor(255, 255, 255); // white 
     if(ClosestColor==1) setColor(255, 110, 0); // orange
     if(ClosestColor==2) setColor(255, 255, 0); // yellow
     if(ClosestColor==3) setColor(255, 0, 0); // red
     if(ClosestColor==4) setColor(0, 255, 0); // green
     if(ClosestColor==5) setColor(0, 0, 255); // blue
     if(ClosestColor==6) setColor(0, 0, 0); // switch RGB LED off

in the part were it saids " MaxDiff=maximum(ColorArray,3);" it got this:

“Robot_Chameleon.ino: In function ‘void GetColor()’:
Robot_Chameleon:108: error: ‘maximum’ was not declared in this scope.”

in this peculiar line I got the mayor problem, becouse whit out that line the board do nathing and i what a full color censor. Please help :slight_smile:


Did you install the Average.h library?

In case you want to try something different, my TCS3200 library (repository link below) also has an example of how to recognise colours.

ok marco_c, I check your website and I follow the manual Instruction and Download the pack "TCS230 TCS3200 RGB Color Sensor Library",I try to locate the sketchbook folder on the program folder and nothing, next I Uncompress the zip file in "C:\Program Files (x86)\Arduino\libraries" where I think it maybe work and I still get the error. :confused: :confused: where is the sketchbook folder? and what pack of libraries I need to download?

enyway thanks for the Reply marco_c and JimboZA

The sketchbook folder is where your Arduino sketches are saved. This could be different on different computers as you configure it in the preferences for the IDE.

I just Download the Average.h library from JimboZA and all the packs of marco_c, put it in "C:\Users\Milan\Documents\Arduino\libraries" and restart arduino hoping that something is going to happen but the problem still there. :(

"Robot_Chameleon.ino: In function 'void GetColor()': Robot_Chameleon:108: error: 'maximum' was not declared in this scope."

eneyway the labraries are working fine but the error continues. :confused: so there is a posible accion that i did wrong?

on the page of the creator is some one that have the same problem i have:

"Robot_Chameleon.ino: In function 'void GetColor()': Robot_Chameleon:108: error: 'maximum' was not declared in this scope."

it is becouse i still have lack of library files?

Just to be clear, simply adding my library to your hard disk will not solve the problem. You actually need to use the examples from the library INSTEAD of the one where you have a problem.

From the error it looks like there is an undeclared variable. You need to go back to the author and report it as a bug.

hallo again, I just make some improvements by downloading the new arduino software and a lot of problems in other projects are gone soo now that i come back to the chameleon project the "Maximum" error coding is gone so I just gona say thanks for the help for all the people that help me.

How i solve the problem: the problem was gone when i download the new arduino software the 1.6 edition and suddenly i check the coding and tada the problem disappear because all the library code that i need to read and check is already in the program.

¡¡another question solve by arduino members¡¡