0% found this document useful (0 votes)
36 views

Source Code

This document describes code for an Arduino project that uses a servo motor to automatically retract or extend a clothesline based on temperature and light sensor readings, displaying the temperature on an LCD screen. The code includes functions to initialize sensors and motors, take continuous temperature and light readings, and move the servo in different positions depending on the sensor values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Source Code

This document describes code for an Arduino project that uses a servo motor to automatically retract or extend a clothesline based on temperature and light sensor readings, displaying the temperature on an LCD screen. The code includes functions to initialize sensors and motors, take continuous temperature and light readings, and move the servo in different positions depending on the sensor values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <Servo.

h>
#include <LiquidCrystal.h>
LiquidCrystal lcd (12, 11, 5, 4, 3, 2);

float C, F;

Servo myservo;

int pos = 0;
long suhu;

void setup(){
myservo.attach(9);
Serial.begin(9600);
lcd.begin(16,2);

lcd.setCursor(1,0);lcd.print("Jemuran");
lcd.setCursor(1,1);lcd.print("Otomatis");

delay(1000);
lcd.clear();

lcd.setCursor(0,0);lcd.print("C : ");
lcd.setCursor(0,1);lcd.print("F : ");
}

void loop(){
int sensorValue = analogRead(A0);

Serial.println(sensorValue);

suhu = analogRead(A1);
C = (500*suhu)/1024;
F = (C*1.8)+32;

lcd.setCursor(5,0);lcd.print(C);
lcd.setCursor(5,1);lcd.print(F);

//Saat Cuaca Mendung


if((sensorValue<10)&&(C>25)){
//Motor Mundur
pos = 0;
while (pos <= 180){
pos += 1;
}
myservo.write(pos);
delay(15);
}
else if ((sensorValue<10)&&(C<25)){
//Motor Mundur
pos = 0;
while (pos <= 180){
pos += 1;
}
myservo.write(pos);
delay(15);
}
//Saat Cuaca Panas
else if((sensorValue>15)&&(C>25)){
//Motor Maju
pos = 180;
while (pos >= 0){
pos -= 1;
}
myservo.write(pos);
delay(15);
}
else if ((sensorValue>15)&&(C<25)){
//Motor Mundur
pos = 0;
while (pos <= 180){
pos += 1;
}
myservo.write(pos);
delay(15);
}
}

You might also like