Hello,
I am new to using Arduino and I am using Arduino Uno R3 to do my projects. I have been trying to include a motor into my program but it will simply not go on. I am trying to program the motor to start running when a certain temperature is reached, please kindly assist. this is my code :
#include <LiquidCrystal.h>
#define sensorPin A0
#define rs 12
#define en 11
#define d4 5
#define d5 4
#define d6 3
#define d7 2
const int alarm = 8;
int dcmotor = 10;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
lcd.begin(16, 2);
}
void loop() {
pinMode(13,OUTPUT);
pinMode(8,OUTPUT);
pinMode(7,OUTPUT);
pinMode(10,OUTPUT);
int analogValue;
float temp;
analogValue = analogRead(sensorPin);
temp = float(analogValue)/1023;
temp = temp*500;
//////
lcd.setCursor(0,1);
lcd.print(temp);
lcd.print((char)223);
lcd.print("C");
/////////
if(temp >= 27.1 && temp <= 125){
digitalWrite(dcmotor,HIGH);
lcd.setCursor(0,0);
lcd.print("HIGH TEMP");
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13,LOW);
delay(200);
tone(alarm,500);
delay(400);
noTone(alarm);
}
else if(temp <= 27 && temp >= -50 ){
lcd.setCursor(0,0);
lcd.print("TEMPERATURE:");
digitalWrite(7, HIGH);
delay(600);
digitalWrite(7,LOW);
}
}