Modul 2 Percobaan 1


Percobaan 1

ADC-Sensor LDR dengan LCD 

1. Foto Hardware dan Diagram Blok [Kembali]

Hardware :



Diagram Blok:





2. Prosedur Percobaan  [Kembali]

+ Rangkai semua komponen 
+ buat program di aplikasi arduino IDE
+ setelah selesai masukkan program ke arduino 
+ jalankan program pada simulasi dan cobakan dengan modul






4. Flowchart dan Listing Program [Kembali]

Flowchart :




Listing Program:

#include <LiquidCrystal.h>

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

int sw1 = 2;
int sws[]={3,4,7};
int numsw = 3;
int front = 6;
int back = 5;

void setup() {
  // put your setup code here, to run once:
lcd.begin(16,2);
pinMode(sw1,INPUT);
for(int thesw = 0; thesw < numsw; thesw++){
  pinMode(sws[thesw],INPUT);
}
pinMode(front,OUTPUT);
pinMode(back,OUTPUT);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
int s1 = digitalRead(sw1);
int ldr = analogRead(A0);
if(s1 == HIGH){
  int activesw = 0;

  for(int thesw = 0; thesw < numsw; thesw++){
    if(digitalRead(sws[thesw]) == HIGH){
      activesw++;
    }
  }
Serial.print("Number of Switch : ");
Serial.println(activesw);
delay(200);
switch(activesw){
  case 0 :
  lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(ldr);
    lcd.setCursor(0,1);
    lcd.print("The LDR Value");
    delay(200);
    break;
 
  case 1 :
  lcd.clear();
    lcd.setCursor(2,0);
    lcd.print("Running The");
    lcd.setCursor(2,1);
    lcd.print("Motor");
    digitalWrite(front,HIGH);
    digitalWrite(back,LOW);
    delay(200);
    break;

  case 2 :
  lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("LDR Value : ");
    lcd.setCursor(13,0);
    lcd.print(ldr);
    if(ldr < 550){
      lcd.setCursor(0,1);
      lcd.print("                 ");
      lcd.setCursor(0,1);
      lcd.print("turn Motor right");
      digitalWrite(front,HIGH);
      digitalWrite(back,LOW);
    }else{
      lcd.setCursor(0,1);
      lcd.print("                 ");
      lcd.setCursor(0,1);
      lcd.print("turn Motor left");
      digitalWrite(front,LOW);
      digitalWrite(back,HIGH);
    }
    break;

  case 3 :
  int pwm = map(ldr,0,1023,0,255);
    digitalWrite(back,LOW);
    analogWrite(front,pwm);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("PWM = ");lcd.print(pwm);
    lcd.setCursor(0,1);
    lcd.print(" Control ???");
    delay(200);
    break;

}
delay(10);
}else{
  lcd.clear();
  lcd.setCursor(4,0);
  lcd.print("ELECTRONIC");
  lcd.setCursor(0,1);
  lcd.print("&INSTRUMENTATION");
  delay(100);
}
}

5. Video Demo [Kembali]

                                      

5. Kondisi [Kembali]

    LDR akan melakukan variasi nilai ADC untuk menghasilkan output berdasarkan masing-masing switch LED yang menghasilkan mekanisme output yang berbeda yang berbeda-beda sesuai logika yang diatur pada listing program.

6. Video Praktikum [Kembali]

                                             


᭒ HTML↠ klik disini
Listing Program↠ klik disini
Video Percobaan↠ klik disini

 Rangkaian Simulasi ->> klik disini



Tidak ada komentar:

Posting Komentar

M3 P5

[KEMBALI KE MENU SEBELUMNYA] DAFTAR ISI 1. Foto Hardware dan Diagram Blok 2. Prosedur Percobaan 3. Rangkaian Simulasi ...