user35398: 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);


user7508: Here is the proper way to implement a polynomial function. It's a direct
application of Horner's
method:
// Polynomial function for output 1.
static float f1(float x)
{
    return (((8.8e-4 * x - 0.0034) * x + 0.37) * x - 6.7) * x + 1.7e2;
}

You would use it like this:
void loop()
{
    for (int x = 0; x < 10; x++) {
        analogWrite(LED, f1(x));
        delay(10);
    }
    digitalWrite(LED, LOW);
    delay(500);
}


35398: <p>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!</p>

<pre><code>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 &lt; 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);
</code></pre>
 7508: <p>Here is the proper way to implement a polynomial function. It's a direct
application of <a href="https://en.wikipedia.org/wiki/Horner%27s_method" rel="nofollow noreferrer">Horner's
method</a>:</p>



<pre class="lang-cpp prettyprint-override"><code>// Polynomial function for output 1.
static float f1(float x)
{
    return (((8.8e-4 * x - 0.0034) * x + 0.37) * x - 6.7) * x + 1.7e2;
}
</code></pre>

<p>You would use it like this:</p>

<pre class="lang-cpp prettyprint-override"><code>void loop()
{
    for (int x = 0; x &lt; 10; x++) {
        analogWrite(LED, f1(x));
        delay(10);
    }
    digitalWrite(LED, LOW);
    delay(500);
}
</code></pre>
