I try to change the brightness of an LED following the formular in out1. I'm pretty sure that something is going wrong because it doesn't really change its brightness and it never stops lightening. Can pleas somebody help me. It should basically do the same than a sin wave but instead of the sin I try to use my equation!
const int LED = 11;
const int LED1 = 10;
const int LED2 = 9;
void setup()
{
}
void loop()
{
float in1, out1, out2, out3;
for (in1 = 0; in1 < 10; in1++)
{
out1 = 8.8 * pow(10,-4) * pow(in1,4) - 0.0034 * pow(in1,3) +0.37* pow(in1,2) -6.7 *in1 +1.7 *pow(10,2);
//out2 = 1.207*pow(in1,4)-0.0011*pow(in1,3)+0.16*pow(in1,2)-5.5*in1+2,0763;
//out3 = 4.829*pow(in1,4)-0.034*pow(in1,3)+0.37*pow(in1,2)-6.7*in1+2,076;
analogWrite(LED,out1);
delay(10);
//analogWrite(LED1,out2);
//analogWrite(LED2,out3);
}
analogWrite(LED,LOW);
/*analogWrite(LED,out1);
analogWrite(LED1,out2);
analogWrite(LED2,out3);
//analogWrite(LED1,LOW);*/
delay(500);
8.8 * pow(10,-4)
”. You mean8.8e-4
. And you should implement Horner's method instead of using the (very expensive)pow()
function.