I need help in my new project

i worked on an STM32 2 weeks ago, but it seems that it’ll be alot easier if i changed my ùcontroller to Arduino, i just need some help cause i’m new to arduino environement.

Well to be brief,

  1. i declare my variables : courant, tension, puissance, derivé, alpha, tension0=0 and puissance0=0.

  2. Now it’s simple, i want to convert 2 analog entries coming from a source

==> entry 1: tension entreey : courant

  1. I calculate

puissance=courant*tension;

derive=(puissance-puissance0)/(tension-tension0);

if(derive==0)

{

alpha =alpha0;

}

else if (derive>0)

{

alpha=alpha0+1;

}

else

{

alpha=alpha0-1;

}

alpha0=alpha;

tension0=tension;

puissance0=puissance;

  1. Finally from the variable “alpha” that i get in the end, i want to generate a variable PWM signal with a frequency of 5KHz

Was there a question in there ?

http://arduino.cc/en/Reference/AnalogWrite

http://playground.arduino.cc/Code/PwmFrequency