Jemuran Anti Hujan Berbasis Arduino

Project Untuk Kelompok 1




Komponen yang dibutuhkan :
  • Arduino (Versi apapun) >> 1 Buah.
  • Motor DC (Motor Tamiya) >> 1 Buah.
  • LDR >> 1 Buah.
  • Resistor 1K >> 1 Buah.
  • Button >> 2 Buah.
  • Kabel >> Seperlunya.
  • Tali >> Seperlunya.

Wiring :


    Source Code:
     /*  
      * Generated Code by Kang Kamal  
      * kangkamal.blogspot.com  
      */  
     int data = 0;  
     int pinLDR  = A0;  
     int pinMotor1 = 5;  
     int pinMotor2 = 6;  
     int tombol1  = 7;  
     int tombol2  = 8;  
     void setup() {  
      // put your setup code here, to run once:  
      Serial.begin(9600);  
      pinMode(pinMotor1, OUTPUT);  
      pinMode(pinMotor2, OUTPUT);  
      pinMode(tombol1, INPUT_PULLUP);  
      pinMode(tombol2, INPUT_PULLUP);  
     }  
     void loop() {  
      // put your main code here, to run repeatedly:  
      data = analogRead(pinLDR); //Masukkan nilai LDR ke variabel "data"  
      Serial.print("Nilai LDR : ");  
      Serial.println(data);  
      if (data > 200){ //Jika tidak mendeteksi matahari (mendung);  
       mundur();  
       if(digitalRead(tombol1 == LOW)){ //Jika tombol tertekan >> STOP  
        stop();  
       }  
      }  
      else{ //Jika kembali panas  
       maju();  
       if(digitalRead(tombol2 == LOW)){ //Jika tombol tertekan >> STOP  
        stop();  
       }  
      }  
     }  
     void maju(){  
      digitalWrite(pinMotor1, HIGH);  
      digitalWrite(pinMotor2, LOW);  
     }  
     void mundur(){  
      digitalWrite(pinMotor1, LOW);  
      digitalWrite(pinMotor2, HIGH);  
     }  
     void stop(){  
      digitalWrite(pinMotor1, LOW);  
      digitalWrite(pinMotor2, LOW);  
     }  
    

    comment 0 comments:

    Post a Comment

    CNC Tutorial Cetak si SAM Assistant

     
    © All 4 You... | Design by Blog template in collaboration with Concert Tickets, and Menopause symptoms
    Powered by Blogger