아두이노 - LCD 시계 | Arduino - LCD Clock

이 튜토리얼에서는 LCD 시계를 만드는 방법을 배우려고 합니다:

두 가지 RTC 모듈 중 하나를 선택할 수 있습니다: DS3231과 DS1307. DS3231과 DS1307 비교를 확인하세요.

준비물

1×Arduino Uno Amazon
1×USB 2.0 cable type A/B 쿠팡 | Amazon
1×LCD I2C 쿠팡 | Amazon
1×Real-Time Clock DS3231 Module Amazon
1×(Alternatively) Real-Time Clock DS1307 Module Amazon
1×CR2032 battery Amazon
1×Breadboard 쿠팡 | Amazon
1×Jumper Wires Amazon
1×(Optional) 9V Power Adapter for Arduino Amazon
1×(Recommended) Screw Terminal Block Shield for Arduino Uno 쿠팡 | Amazon
1×(Optional) Transparent Acrylic Enclosure For Arduino Uno Amazon
공개: 이 섹션에서 제공된 링크 중 일부는 제휴 링크입니다. 이 링크를 통해 구매한 경우 추가 비용없이 수수료를 받을 수 있습니다. 지원해 주셔서 감사합니다.

LCD, DS3231 및 DS1307 RTC 모듈에 관하여

LCD, DS3231 및 DS1307(핀아웃, 작동 방식, 프로그래밍 방법 등)에 대해 잘 모른다면, 다음 튜토리얼에서 배우세요:

LCD 및 RTC 라이브러리 설치

  • Arduino IDE의 왼쪽 바에서 Libraries 아이콘으로 이동하세요.
  • “LiquidCrystal I2C”를 검색한 다음, Frank de Brabander가 만든 LiquidCrystal_I2C 라이브러리를 찾으세요.
  • LiquidCrystal_I2C 라이브러리를 설치하려면 Install 버튼을 클릭하세요.
Arduino LiquidCrystal I2C library

"RTClib"을 검색한 다음, Adafruit에서 제공하는 RTC 라이브러리를 찾으세요. 이 라이브러리는 DS3231과 DS1307 모두와 호환됩니다.

RTC 라이브러리를 설치하려면 Install 버튼을 클릭하세요.

Arduino RTC library
  • 다른 라이브러리 종속성을 설치하라는 요청을 받을 수 있습니다
  • 모든 라이브러리 종속성을 설치하려면 Install All 버튼을 클릭하세요.
Arduino rtc dependency library

DS3231 RTC 모듈에서 시간을 읽어 LCD에 표시하기

배선도

Arduino DS3231 LCD Wiring Diagram

이 이미지는 Fritzing을 사용하여 만들어졌습니다. 이미지를 확대하려면 클릭하세요.

아두이노 코드 - DS3231과 LCD

/* * 이 Arduino 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino/arduino-lcd-clock */ #include <LiquidCrystal_I2C.h> #include <RTClib.h> LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C 주소 0x27 (DIYables LCD로부터), 16열과 2행 RTC_DS3231 rtc; void setup() { Serial.begin(9600); lcd.init(); // LCD를 초기화합니다 lcd.backlight(); // 백라이트를 켭니다 // RTC 모듈 설정 if (!rtc.begin()) { Serial.println("Couldn't find RTC"); Serial.flush(); while (true) ; } // 이 스케치를 컴파일한 PC의 날짜 & 시간으로 RTC를 자동 설정합니다 rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); } void loop() { DateTime now = rtc.now(); int year = now.year(); int month = now.month(); int day = now.day(); int hour = now.hour(); int minute = now.minute(); int second = now.second(); lcd.clear(); lcd.setCursor(0, 0); // 첫 번째 행에서 출력을 시작합니다 lcd.print("Date: "); lcd.print(year); lcd.print("/"); lcd.print(month); lcd.print("/"); lcd.print(day); lcd.setCursor(0, 1); // 두 번째 행에서 출력을 시작합니다 lcd.print("Time: "); lcd.print(hour); lcd.print(":"); lcd.print(minute); lcd.print(":"); lcd.print(second); delay(1000); // 매 초마다 업데이트 }

사용 방법

  • 위의 코드를 복사하고 Arduino IDE로 열기
  • 코드를 Arduino로 업로드하려면 Arduino IDE에서 Upload 버튼을 클릭하세요.
  • 결과를 LCD에서 확인하세요

DS1307 RTC 모듈에서 시간을 읽어 LCD에 표시하기

배선도

Arduino DS1307 LCD Wiring Diagram

이 이미지는 Fritzing을 사용하여 만들어졌습니다. 이미지를 확대하려면 클릭하세요.

아두이노 코드 - DS1307과 LCD

/* * 이 Arduino 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino/arduino-lcd-clock */ #include <LiquidCrystal_I2C.h> #include <RTClib.h> LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C 주소 0x27 (from DIYables LCD), 16열 및 2행 RTC_DS1307 rtc; void setup() { Serial.begin(9600); lcd.init(); // lcd를 초기화 lcd.backlight(); // 백라이트 켜기 // RTC 모듈 설정 if (!rtc.begin()) { Serial.println("Couldn't find RTC"); Serial.flush(); while (true) ; } // 이 스케치가 컴파일된 PC의 날짜 및 시간으로 RTC를 자동 설정 rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); } void loop() { DateTime now = rtc.now(); int year = now.year(); int month = now.month(); int day = now.day(); int hour = now.hour(); int minute = now.minute(); int second = now.second(); lcd.clear(); lcd.setCursor(0, 0); // 첫 번째 행에 인쇄 시작 lcd.print("Date: "); lcd.print(year); lcd.print("/"); lcd.print(month); lcd.print("/"); lcd.print(day); lcd.setCursor(0, 1); // 두 번째 행에 인쇄 시작 lcd.print("Time: "); lcd.print(hour); lcd.print(":"); lcd.print(minute); lcd.print(":"); lcd.print(second); delay(1000); // 1초마다 업데이트 }

사용 방법

  • 위의 코드를 복사하여 아두이노 IDE로 열기
  • 아두이노에 코드를 업로드하기 위해 아두이노 IDE에서 Upload 버튼을 클릭하세요
  • LCD에서 결과를 확인하세요

동영상

비디오 제작은 시간이 많이 걸리는 작업입니다. 비디오 튜토리얼이 학습에 도움이 되었다면, YouTube 채널 을 구독하여 알려 주시기 바랍니다. 비디오에 대한 높은 수요가 있다면, 비디오를 만들기 위해 노력하겠습니다.

※ OUR MESSAGES

  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!