Tugas Pendahuluan Modul 2
1. Kondisi[Kembali]
Bila suhu yang terbaca pada lcd menunjukkan suhu > 25 derajat celcius maka motor akan berputar ke kiri.
2. Rangkaian Simulasi[Kembali]
4. Listing Program[Kembali]
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
float tempC;
int tempPin = A0, hasil;
char a[16];
int Tr1 = 0;
int Tr2 = 1;
int Tr3 = 8;
int Tr4 = 9;
int pwm = 10;
void setup() {
// put your setup code here, to run once:
pinMode(Tr1, OUTPUT);
pinMode(Tr2, OUTPUT);
pinMode(Tr3, OUTPUT);
pinMode(Tr4, OUTPUT);
pinMode(pwm, OUTPUT);
Serial.begin(9600);
lcd.begin(16, 2);
lcd.print("Temperatur:");
}
void loop() {
// put your main code here, to run repeatedly:
lcd.setCursor(0, 1);
hasil = ((5 * analogRead(tempPin) * 100) / 1024);
sprintf(a, "suhu=%d", hasil);
lcd.print(a);
if(hasil > 25)
{
analogWrite(pwm, 128);
digitalWrite(Tr1, HIGH);
digitalWrite(Tr2, LOW);
digitalWrite(Tr3, HIGH);
digitalWrite(Tr4, LOW);
}
else
{
digitalWrite(Tr1, LOW);
digitalWrite(Tr2, LOW);
digitalWrite(Tr3, LOW);
digitalWrite(Tr4, LOW);
}
}
5. Video[Kembali]
6. Link Download[Kembali]
Download rangkaian proteus Disini
Download video rangkaian
Download program arduino Disini
Komentar
Posting Komentar