Page 100 - 1
P. 100
strip.setPixelColor(24, m); int hours = tm.Hour;
} // 시(hour) 데이터를 hours 변수에 담는다.
else if (minutes > 54 && minutes < 60) { int minutes = tm.Minute;
if(minutes%5==0) // 분(minute) 데이터를 minutes 변수에 담는다.
m = strip.Color(232, 104, 80, 0);//1 int seconds = tm.Second;
else if(minutes%5==1) // 초(second) 데이터를 seconds 변수에 담는다.
m = strip.Color(255, 216, 0, 0);//2
else if(minutes%5==2) // 시 분 초 출력, ,
m = strip.Color(88, 200, 88, 0);//3 Serial.print(hours);
else if(minutes%5==3) Serial.print("\t");
m = strip.Color(88, 116, 152, 0);//4 Serial.print(minutes);
else if(minutes%5==4) Serial.print("\t");
m = strip.Color(153, 102, 153, 0);//5 Serial.println(seconds);
strip.setPixelColor(21, m);
strip.setPixelColor(22, m);
strip.setPixelColor(23, m);
strip.setPixelColor(24, m);
} // 5 분에 한번씩 led 초기화
else; if ((minutes % 5) == 0 && seconds == 0) {
} ledReset();
}
void ledReset() {
for (int i = 0; i < 25; i++) {
strip.setPixelColor(i, 0, 0, 0); hoursFilter(hours, minutes);
strip.show(); // 시(hour) LED 출력
} minutesFilter(minutes);
} // 분(minute) LED 출력
strip.show();
void setup() { }
Serial.begin(9600); else {
#if defined (__AVR_ATtiny85__) if (RTC.chipPresent()) {
if (F_CPU == 16000000) Serial.println("The DS1307 is stopped. Please
clock_prescale_set(clock_div_1); run the SetTime");
#endif Serial.println("example to initialize the time and
strip.begin(); begin running.");
strip.show(); Serial.println();
while (!Serial) ; // 시리얼 통신이 가능할 때까지 대 }
기. else {
delay(200); Serial.println("DS1307 read error! Please
} check the circuitry.");
Serial.println();
void loop() { }
tmElements_t tm; // RTC 객체 선언 delay(9000);
}
if (RTC.read(tm)) { //RTC 모듈로 부터 데이터가 들 delay(1000);
어온다면 }
나. Tiny RTC 소스코드
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
void setup () {
Serial.begin(9600);
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {
- 100 -