Hello,
I'm working on a DC motor speed project using ATmega168 on (Freeduino SB) and Arduino software.
Simply the user can spacify the required temperature + sensor feedback of the current temperature (analog inputs ) to Arduino, to run the fan in a suitable speed.
I have ordered the hardware, though I am eorking on the code but it looks like a big mess :-?.
The thing is I have been browsing the forum in two days and I got confused of the different solution to manipulate the DC motor speed.
The Big Question is , is this a right code? remember I don't have the hardware yet.
I just can't believe it! is it that simple! :
// DC motor
#include <PID_Beta6.h>
//Define Variables we'll be connecting to
double Setpoint, Input, Output;
//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint,2,5,1);
void setup()
{
//initialize the variables we're linked to
Input = analogRead(0); //read from sensor (LM35D)
Setpoint = analogRead(1); //knob 0-5 V
//turn the PID on
myPID.SetMode(AUTO);
}
void loop()
{
Input = analogRead(0);
Setpoint = analogRead(1);
myPID.Compute();
analogWrite(3,Output); //DC motor (fan) 0-5V
}
Thanks in advance