Code
Code
h>
#include <SoftwareSerial.h>
//declare
variables float
VoltOut; float
voltOut; float
speed; float D;
T; float V; int
speedlPin; int
tempPin=4; int
fanSpeed; int
voltPin=1; int
temp; int
fanLCD;
speed1Pin=2;
setup(){
pinMode(fan, OUTPUT);
pinMode(led, OUTPUT);
lcd.begin(16, 4);
lcd.print("T=");
lcd.setCursor(0, 1);
lcd.print("V=");
lcd.setCursor(9, 0);
lcd.print("I=");
lcd.setCursor(9, 1);
lcd.print("S=");
Serial.begin(9600);
void loop()
mytemp [i]=analogRead(tempPin);
delay(10);
V=
analogRead(voltPin); I=
analogRead(curtPin); int
avrVolt=0;
myVolt [i]=analogRead(voltPin);
delay(10);
SD = analogRead(speedlPin);
VoltOut = (5*avrVolt*46)/1023;
curt= (5*I)/1023;
current=(5*I*4)/1023;
speed=(5*SD*15)/1023;
D=(5*SD)/1023;
lcd.setCursor(2, 0);
lcd.print(tempC,1);lcd.print("C"); lcd.setCursor(11,
0); lcd.print(current,1);
lcd.print("A");
lcd.setCursor(11, 1);
lcd.print(speed,1);
lcd.print("rpm"); if(VoltOut>
230){ lcd.print("OVER
if(current >16)
delay(5);
if(tempC>tempMax)
delay(5);
digitalWrite(fan, LOW);
if((tempC >= tempMin) && (tempC <= tempMax)) { // if temperature is higher than
minimum temp
fanSpeed = map(tempC, tempMin, tempMax, 32, 255); // the actual speed of fan
fanLCD = map(tempC, tempMin, tempMax, 0, 100); // speed of fan to display on LCD
digitalWrite(fan, LOW);
digitalWrite(led, LOW);