Skip to content

Instantly share code, notes, and snippets.

@neosarchizo
Created October 5, 2015 04:04
Show Gist options
  • Save neosarchizo/57432eed517ab3cacdce to your computer and use it in GitHub Desktop.
Save neosarchizo/57432eed517ab3cacdce to your computer and use it in GitHub Desktop.
[ICT DIY] 아두이노로 화분 습도 센서 제어하기
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define RED 3
#define GREEN 4
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
lcd.init();
lcd.backlight();
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
}
void loop()
{
int humidity = map(analogRead(A0), 0, 1023, 100, 0);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Humidity : ");
lcd.print(humidity);
lcd.print("%");
lcd.setCursor(0, 1);
if (humidity > 35) {
digitalWrite(GREEN, HIGH);
digitalWrite(RED, LOW);
lcd.print("I'm OK!");
}
else {
digitalWrite(GREEN, LOW);
digitalWrite(RED, HIGH);
lcd.print("Give Me Water!");
}
delay(1000);
}
@w56thrhtdhs
Copy link

구매해보고 안되서 이래저래 하다보니까 0x27 -> 0x3F 로 하시면 됩니다~

@neosarchizo
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment