Perancang Alat Ukur Kadar Gas Karbon Monoksida (CO) Pada Emisi Gas Buang Kendaraan Berbasis Arduino

LAMPIRAN

Universitas Sumatera Utara

LAMPIRAN PROGRAM
#include

LiquidCrystal lcd(12, 10, 9,8,7,6);

void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("NAMA:DARA ZALINA");
lcd.setCursor(0, 1);
lcd.print("NIM :132411038");
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("A. UKUR KADAR CO");
delay(1000);

lcd.clear();
}

void loop() {
int sensor=analogRead(A0);
float hasil = sensor/3.4;
lcd.setCursor(0, 0);
lcd.print(hasil);
lcd.setCursor(6, 0);
lcd.print("PPM");
if (hasil < 50)
{
lcd.setCursor(0, 1);
lcd.print("BAIK !!! ");
delay(100);

Universitas Sumatera Utara

}
else if (hasil > 50 && hasil < 100)

{
lcd.setCursor(0, 1);
lcd.print("SEDANG !!! ");
delay(100);
}
else if (hasil > 100)
{
lcd.setCursor(0, 1);
lcd.print("BURUK !!! ");
delay(100);
}
delay(200);
lcd.clear();

}

Universitas Sumatera Utara

Universitas Sumatera Utara