Automatic clothesline system


this code
#include <Stepper.h>
#include <MilliStopper.h>
#include (Stepper.h)

cosnt int stepsPerRevolution = 200; // Seusaikan step motor

// Inisialisasi Pin in1 =8, in2=9, in3=10, in4=11.
stepper myStepper(stepsPerRevolution,8,10,9,11);

cosnt int button1Pin = 3; // Button 1 di Pin 3 (menjemur jemuran)
cosnt int button2Pin = 4; // Button 2 di Pin 4 (menarik jemuran)
cosnt int hujanPin = A0; // Pin analog tempat sensor hujan terhubung

int kondisi = 0; // 0; tidak hujan, 1;hujan

//Jumlah step yang diperlukan untuk 39 putaran
cosnt int stepsFor39Turns + 7800; // 39 putaran 200 step/putaran = 7800 step

void setup() (
Serial.begin(9600); //Memulai serial monitor

pinMode(button1Pin. INPUT_PULLUP); // Menggunakan pullup internal
pinMode(button2Pin. INPUT_PULLUP); // Menggunakan pullup internal
pinMode(hujanPin.INPUT);

myStepper.setSpeed(100); // Mengatur kecepatan atau speed dari motor stepper

Serial.println("Sistem Jemuran Otomatis Siap");
}

void loop(){
int hujan Value = analogread(hujanPin);
Serial.print("Nilai Sensor Hujan;");
Serial.print(hujanValue);

//Logika deteksi kondisi hujan atau cerah
if (hujanValue <= 500 && kondisi ==0) { // Kondisi saat hujan terdeteksi
Serial.ptintln("Deteksi;Hujan");
Serial.ptintln("Menarik Jemuran (39 putaran)...");
myStepper.step(stepsFor39Turns); // Menarik jemuran (39 putaran)
delay(1000);
kondisi = 1; // Menandakan kondisi hujan
} else if (hujanValue >=700 && kondisi == 1 ) { // kondisi saat cerah
Serial.println("Deteksi; Cerah");
Serial.println("Menjemur pakaian (39 putarran)...");
myStepper.step(-stepsFoor39Turns); // Menjemur pakaian (39 putaran)
delay(1000);
kondisi = 0; // Menandakan kondisi cerah
}

// Logika untuk menarik pakaian (button 2)
if (digitalRead(button2Pin) == LOW){
Serial.printIn("Tombol 2 ditekan: Menarik jemuran...");
myStepper.step(-stepsFor39Turns): //Bergerak mundur untuk menjemur jemuran
}

//Logika untuk menjemur pakaian (button 1)
if (digitalRead(button1Pin) == LOW) {
Serial.printIn("Tombol 1 ditekan: Menjemur pakaian...");
myStepper.step(-stepFor39Turns): // Bergerak mundur untuk menjemur jemuran
}

// Jika kedua tombol tidak ditekan. motor akan berhenti
if (digitalRead(button1Pin) == HIGH && digitalRead(button2Pin) == HIGH) {
Serial.printIn("Kedua tombol dilepas: Motor berhenti.");
//Tidak melakukan apapun saat tombol dilepas
}

Serial.printIn("Sistem Stand by");

Welcome to the forum

As your topic does not relate directly to the installation or operation of the IDE it has been moved to the Programming category of the forum

As a matter of interest, what version of the IDE are you using ?

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Please post your sketch, using code tags when you do

Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

Do you have a question ?

Your other topic on the same subject deleted.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.