You are on page 1of 1

const int temp=A0, motor=9;

float val=0.0;

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
pinMode(motor,OUTPUT);
lcd.begin(16, 2);
lcd.print("hello, world!");
lcd.setCursor(0, 0);
lcd.print("MOTOR PROJECT");
}

void loop() {
val=analogRead(temp);
val=val*4.887; // convert raw data into millivolts
val=val/10.0; // converting millivolts into deg C

lcd.setCursor(0, 1);
lcd.print("TEMP: ");
lcd.print(val);

if(val>0 && val<15)


analogWrite(motor,0); // 0% duty cycle

if(val>=15 && val<25)


analogWrite(motor,63); // 25% duty cycle

if(val>=25 && val<50)


analogWrite(motor,127); // 50% duty cycle

if(val>=50 && val<75)


analogWrite(motor,190); // 75% duty cycle

if(val>=75)
analogWrite(motor,255); // 100% duty cycle

delay(10); // 10ms delay