M
M
martin19682015-12-28 18:42:33
Arduino
martin1968, 2015-12-28 18:42:33

What are these errors in the Arduino code?

/* Robot Chameleon based on TCS3200 COLOR SENSOR and RGB LED
Author: Markus Bindhammer
Date: 2-6-2014
*/
//*********************** ***************** LIBRARIES *********************************** *******
#include // See playground.arduino.cc/Main/Average
//****************************** ********* 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() {
RGB_LED_Setup();
TCS3200_Setup();
}
void loop() {
GetColor();
delay(200);
}
//**************************************** 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() {
pinMode(S0,OUTPUT);
pinMode(S1,OUTPUT);
pinMode(S2,OUTPUT);
pinMode(S3,OUTPUT);
pinMode(LED,OUTPUT);
pinMode(OUT,INPUT);
}
void TCS3200_On() {
digitalWrite(LED,HIGH); // Switch LED on
digitalWrite(S0,HIGH); //Output frequency scaling (100%)
digitalWrite(S1,HIGH);
delay(5);
}
void TCS3200_Off() {
digitalWrite(LED,LOW); // Switch LED off
digitalWrite(S0,LOW); //Power off sensor
digitalWrite(S1,LOW);
}
void NoFilter() { //Select no filter
digitalWrite(S2,HIGH);
digitalWrite(S3,LOW);
delay(5);
}
void RedFilter() { //Select red filter
digitalWrite(S2,LOW);
digitalWrite(S3,LOW);
delay(5);
}
void GreenFilter() { //Select green filter
digitalWrite(S2,HIGH);
digitalWrite(S3,HIGH);
delay(5);
}
void BlueFilter() { //Select blue filter
digitalWrite(S2,LOW);
digitalWrite(S3,HIGH);
delay(5);
}
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;
TCS3200_On();
NoFilter();
FrequencyClear=500.0/pulseIn(OUT,LOW,10000); // Frequency in kHz
RedFilter();
FrequencyRed=500.0/pulseIn(OUT,LOW,10000); // Frequency in kHz
GreenFilter();
FrequencyGreen=500.0/pulseIn(OUT,LOW,10000); // Frequency in kHz
BlueFilter();
FrequencyBlue=500.0/pulseIn(OUT,LOW,10000); // Frequency in kHz
TCS3200_Off();
//Output frequency blue, green, red percentage represents the ratio of the
//respective color to the Clear channel absolute value:
PercentageRed=int((FrequencyRed/FrequencyClear)*100.0);
PercentageGreen=int((FrequencyGreen/FrequencyClear)*100.0);
PercentageBlue=int((FrequencyBlue/FrequencyClear)*100.0);
//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};
intColorArray[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
ColorArray[0]=abs(SavedColorRed[i_color]-PercentageRed);
ColorArray[1]=abs(SavedColorGreen[i_color]-PercentageGreen);
ColorArray[2]=abs(SavedColorBlue[i_color]-PercentageBlue);
MaxDiff=max(ColorArray,3);
if (MaxDiff

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Martyanov, 2015-12-28
@vilgeforce

Well, of course, there is absolutely no need to write what kind of errors and where they are, right?

M
Max, 2015-12-28
@MaxDukov

well, English-in-white, line 110 - C++ prohibits comparing a pointer and an integer
operands for comparison have different types

if (MaxDiff<MinDiff)
MinDiff = 300
MaxDiff=maximum(ColorArray,3);

M
martin1968, 2015-12-28
@martin1968

Robot_Chameleon.ino: In function 'void GetColor()':
Robot_Chameleon:110: error: ISO C++ forbids comparison between pointer and integer
Robot_Chameleon:110: error: operands to ?: have different types 'int*' and 'int'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question