How to correct the "cannot convert" error?

Hi, everyone,

I’m completly new in Arduino programming but I have a project with the one I’m having troubles, I solved most of them but I don’t seem to understand how to solve this one:

ProyectoFin1:194: error: cannot convert 'int*' to 'double*' for argument '1' to 'double FuzzySysT1(double*, int (*)[4])'

exit status 1
cannot convert 'int*' to 'double*' for argument '1' to 'double FuzzySysT1(double*, int (*)[4])'

As I understand it is taking the first argument as double, but I’ve declared it as int, too, that’s why I don’t understand why is this happening. I’m working with three sensors, DHT11 and a photoresistor to check the environment’s comfort with a fuzzy system (that part was given to us), this is the code I have:

#include <dht.h>

int DBm1[125][4]= {
{1, 1, 1, 1},
{1, 1, 2, 1},
{1, 1, 3, 2},
{1, 1, 4, 2},
{1, 1, 5, 1},
{1, 2, 1, 1},
{1, 2, 2, 1},
{1, 2, 3, 2},
{1, 2, 4, 2},
{1, 2, 5, 2},
{1, 3, 1, 1},
{5, 5, 4, 1},
{5, 5, 5, 1}}; //This table is longer but I cut it to show the code

#define THsensor A0 //pin A0 for the DHT11 sensor
dht DHT;

const int analogInPin = A1;  // Analog input pin that the potentiometer is attached to
const int analogOutPin = 3; // Analog output pin that the LED is attached to

int IlumSensor = 0;        // value read from the pot
int outputSensor = 0;        // value output to the PWM (analog out)
int outTemp = 0; //temperature
int outHum = 0; //humidity
int outIlum = 0; //Illumination

void setup(void) {
  Serial.println("Environment Comfort \n \n");
//LEDs for comfort display
  pinMode(8,OUTPUT); //Very Low 
  pinMode(7,OUTPUT); //Low 
  pinMode(6,OUTPUT); //Regular
  pinMode(5,OUTPUT); //High
  pinMode(4,OUTPUT); //Very High


void loop(void) {
    IlumSensor = analogRead(analogInPin); //Light sensor 
  // map it to the range of the analog out:
    outputSensor = map(IlumSensor, 0, 1023, 0, 255);
    // change the analog out value:
    analogWrite(analogOutPin, outputSensor);
//Normalization mapping 
outTemp = map(DHT.temperature, 0, 255, 0, 1);
outHum = map(DHT.humidity, 0, 255, 0, 1);
outIlum = map(IlumSensor,0, 1023, 0, 1);

int THIVecN[3]={outTemp, outHum, outIlum};

    Serial.print("Actual temperature: ");
    Serial.print(" C \n");
    Serial.print("Actual Humidity: ");
    Serial.print("% \n");
    Serial.print("Actual Illumination: ");
    Serial.print(" \n \n");

    int m1 = FuzzySysT1(THIVecN,DBm1);



int reglas=125;
int entradas = 3;
double trapezoidmf(double x,double a,double b,double c,double d){
double mf=max(min(min((x-a)/(b-a+0.000001),1),(d-x)/(d-c+0.0000001)),0);
return mf;
double trianglemf(double x,double a,double b,double c){
double mf=max(min((x-a)/(b-a+0.000001),(c-x)/(c-b+0.000001)),0);
return mf;
double Type1FS(double x,int n,double V[]){
double a=V[0];
double b=V[1];
double c=V[2];
double mf;

if (n== 1){
  return mf;
if (n==2){
  return mf;
if (n==3){
  return mf;
if (n==4){
  return mf;
if (n==5){
  return mf;
if (n==0){
  return mf;
double FuzzySysT1(double X[],int DB[][4])
double PARAM[5][3]={{-1.0, -0.6666, -0.3333}
    ,{-0.6666, -0.3333, 0}
    ,{-0.3333, 0, 0.3333}
    ,{0, 0.3333, 0.6666}
    ,{0.3333, 0.6666, 1}};
double V[3];

double AC[5]={0.166, 0.333, 0.5, 0.665, 0.831};
double Fo[125];
for(int r=0;r<=(reglas-1);r++)
  double sumin=1;
  int n;
  for(int i=0;i<=(entradas-1);i++)
    double mf=Type1FS(X[i],(n+1),V);

  Fo[r] = sumin;

double sum1=0; double sum2=0.00000001;
for(int r=0;r<=(reglas);r++)
double y=sum1/sum2;
return y;

if ((y>=0) && (y<=0.333)) { 
    Serial.print("Very Low Comfort");
} else if ((y>=0.166) && (y<=0.5)) { 
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    Serial.print("Low Comfort");
} else if ((y>=0.333) && (y<= 0.665)) { 
   digitalWrite(8, HIGH);
   digitalWrite(7, HIGH);
   digitalWrite(6, HIGH);
   Serial.print("Good Comfort");
} else if ((y>=0.5) && (y<=0.831)) { 
   digitalWrite(8, HIGH);
   digitalWrite(7, HIGH);
   digitalWrite(6, HIGH);
   digitalWrite(5, HIGH);
   Serial.print("High Comfort");
} else if ((y>=0.665) && (y<=1)) { 
   digitalWrite(8, HIGH);
   digitalWrite(7, HIGH);
   digitalWrite(6, HIGH);
   digitalWrite(5, HIGH);
   digitalWrite(4, HIGH);  
   Serial.print("Very High Comfort");
} else {
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  digitalWrite(6, LOW);
  digitalWrite(5, LOW);
  digitalWrite(4, LOW);
  Serial.print("Out of Range");

Also I’d like to know whether I am right or not: I need that the values that the fuzzy system receive be between 0 and 1 (normalization is how the teacher calls it), he told me that if the signals where analog inputs I had to divide by 1023, I thought it could also work if I mapped them as I did, is what I’m doing correct?

Thanks a lot!

The error message it telling you exactly what the issue is. The FuzzySysT1() function expects a pointer to a double/float but you're giving it THIVecN which is a pointer to an int. Change the THIVecN array declaration to float and it should work.

Thanks, saximus, I changed m1 to float, and THIVecN to double and the error is gone (I changed it to float but the error was still there), there's just a warrning about 'narrowing conversion from int to double' with outHum, outIlum and outTemp, I assume this is because those are int and then I made the vector as double (?)

And for a reason the FuzzySysT1 function does not seems to be working or at least the part about indicating the actual comfort, is there a way I can use 'y' on the void loop() function just to turn on the LEDs? I thought using return y; could send the 'y' variable to the void loop() but as I see it now it's just the sensors part that's working, I don't know what to do about it, thanks!