I'm working with a fuzzy logic controller with Arduino, I'm trying to emulate an AC by entering inputs [temperature and humidity] using two potentiometers and the output is the AC power.
This is the basic part of the program, every thing is good, I can print the values of Temp and HU. But when I try to print the value of the Power, nothing happens, and the serial monitor displays nothing. By trial and error, I can see that Serial.println with power or any variable related to power crashes the program. What may be the reason?
void loop()
{
// Read Input: Temperature
ttemp = analogRead(temp);
Serial.println("the analoge Tempreture is ");
Serial.println (ttemp);
ttemp = map(ttemp, 0, 1023, 5, 65);
ttemp = constrain(ttemp, 5, 65);
Serial.println("the actual Tempreture is ");
Serial.println (ttemp);
Serial.println("-------------------------");
delay(100);
g_fisInput[0] = ttemp;
// Read Input: Humidity
hhu = analogRead(hu);
Serial.println("the analoge Humidity is ");
Serial.println (hhu);
hhu = map(hhu, 0, 1023, 16, 100);
hhu = constrain(hhu, 16, 100);
Serial.println("the actual Humidity is ");
Serial.println (hhu);
Serial.println("-----------------------");
delay(100);
g_fisInput[1] = hhu;
g_fisOutput[0] = 0;
fis_evaluate();
// Set output vlaue: Power
int ppower1 = g_fisOutput[0];
// Serial.println("the actual Power is ");
// Serial.println (ppower1);
ppower = map(ppower1,100,3000,0,255);
ppower = constrain (ppower, 0,255);
analogWrite(power , ppower);
// Serial.println("the analoge Tempreture is ");
//Serial.println (ppower);
// Serial.println("--------------------------");
}