Senin, 25 Maret 2024





Tugas Pendahuluan 1
== Percobaan 1 Kondisi 5 ==


  1. Membuka proteus
  2. Buka file proteus yang sudah disesuaikan dengan kondisi
  3. Running rangkaiannya
  4. Sesuaikan dengan kondisi yang diinginkan



Arduino Uno


LCD
Sensor LDR


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);
}
}


Modul 2: Percobaan 1 Kondisi 5
"Ketika ADC < 200 atau >600) dan semua switch aktif, motor berputar ke kanan 3 detik lalu kiri 4 detik dan muncul karakter pada kolom 1 LCD"




Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © Muhammad Zaky Kurnia - Skyblue - Powered by Blogger - Designed by Johanes Djogan -