-
-
Save neosarchizo/57432eed517ab3cacdce to your computer and use it in GitHub Desktop.
[ICT DIY] 아두이노로 화분 습도 센서 제어하기
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
구매해보고 안되서 이래저래 하다보니까 0x27 -> 0x3F 로 하시면 됩니다~