Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi untuk memonitor kelembaban tanah, alat ini menggunakan arduino dan sensor soil moisture, kemudian interface menggunakan lcd 16x2. untuk lebih jelasnya berikut adalah komponen dan programnya
a. Arduino Uno
b. Sensor Soil Moisture
c. LCD 16x2 + I2C
d. Program Arduino IDE
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int dryValue = 1023;
int wetValue = 0;
int friendlyDryValue = 100;
int friendlyWetValue = 0;
float nddi;
int rawValue;
float mapping;
void setup()
{
lcd.begin();
lcd.clear();
lcd.noCursor();
lcd.backlight();
}
void loop()
{
rawValue = analogRead(A0);
//mapping = map(rawValue, dryValue, wetValue, friendlyDryValue, friendlyWetValue);
//nddi = mapping /100;
nddi = map(rawValue, dryValue, wetValue, friendlyDryValue, friendlyWetValue);
lcd.setCursor(0, 0);
lcd.print("S= ");
lcd.print(nddi);
lcd.print(" ");
/*
if( nddi <= -0.05 ){
lcd.setCursor(0, 1);
lcd.print("AIR ");
}
if(( nddi > -0.05 )&&(nddi <= 0.01 )){
lcd.setCursor(0, 1);
lcd.print("NORMAL ");
}
if(( nddi > 0.01 )&&(nddi <= 0.15 )){
lcd.setCursor(0, 1);
lcd.print("KERING RINGAN ");
}
if(( nddi > 0.15 )&&(nddi <= 0.25 )){
lcd.setCursor(0, 1);
lcd.print("KERING SEDANG ");
}
if(( nddi > 0.25 )&&(nddi <= 1.00 )){
lcd.setCursor(0, 1);
lcd.print("KERING BERAT ");
}
if( nddi > 1.00 ){
lcd.setCursor(0, 1);
lcd.print("KERING SEKALI ");
}
*/
delay(200);
}
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int dryValue = 1023;
int wetValue = 0;
int friendlyDryValue = 100;
int friendlyWetValue = 0;
float nddi;
int rawValue;
float mapping;
void setup()
{
lcd.begin();
lcd.clear();
lcd.noCursor();
lcd.backlight();
}
void loop()
{
rawValue = analogRead(A0);
//mapping = map(rawValue, dryValue, wetValue, friendlyDryValue, friendlyWetValue);
//nddi = mapping /100;
nddi = map(rawValue, dryValue, wetValue, friendlyDryValue, friendlyWetValue);
lcd.setCursor(0, 0);
lcd.print("S= ");
lcd.print(nddi);
lcd.print(" ");
/*
if( nddi <= -0.05 ){
lcd.setCursor(0, 1);
lcd.print("AIR ");
}
if(( nddi > -0.05 )&&(nddi <= 0.01 )){
lcd.setCursor(0, 1);
lcd.print("NORMAL ");
}
if(( nddi > 0.01 )&&(nddi <= 0.15 )){
lcd.setCursor(0, 1);
lcd.print("KERING RINGAN ");
}
if(( nddi > 0.15 )&&(nddi <= 0.25 )){
lcd.setCursor(0, 1);
lcd.print("KERING SEDANG ");
}
if(( nddi > 0.25 )&&(nddi <= 1.00 )){
lcd.setCursor(0, 1);
lcd.print("KERING BERAT ");
}
if( nddi > 1.00 ){
lcd.setCursor(0, 1);
lcd.print("KERING SEKALI ");
}
*/
delay(200);
}
e. VIDEO HASILNYA
No comments:
Post a Comment