<b style="background-color: rgb(255, 255, 255); font-stretch: normal; font-size: 12pt; line-height: normal;">±¸¸ÅÁ¦Ç°: 16°³ ³×¿ÀÇȼ¿ RGBW LED ¸µÅ¸ÀÔ (NeoPixel Ring - 16 x 5050 RGBW LEDs w/ Integrated Drivers - Natural White - ~4500K)</b><div><b style="background-color: rgb(255, 255, 255); font-stretch: normal; font-size: 12pt; line-height: normal;"><br></b></div><div><span style="font-size: 16px; background-color: rgb(255, 255, 255);"><b>¾ÆµÎÀ̳ë¼Ò½º</b></span></div><div><span style="background-color: rgb(255, 255, 255); font-size: 16px;"><b><div>#include <LiquidCrystal.h> // LCD ¸ð´ÏÅÍ Çì´õ</div><div>#include <SoftwareSerial.h> // ½Ã¸®¾ó Åë½Å Çì´õ</div><div>#include <DHT11.h> // ¿Â½Àµµ ¼¾¼</div><div>#include <Wire.h> // RCT</div><div>#include "RTClib.h" // RCT</div><div>#include <Adafruit_NeoPixel.h></div><div><br></div><div>Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, 5, NEO_GRBW + NEO_KHZ800);</div><div>LiquidCrystal lcd(12, 11, 9, 8, 7, 6);</div><div>SoftwareSerial Blue(2, 3);</div><div>DHT11 dht11(4);</div><div>const int sensorPin = A0;</div><div>RTC_DS1307 RTC;</div><div>int lightLevel;</div><div>int brightness;</div><div><br></div><div><br></div><div>void setup() {</div><div> Serial.begin(9600); //½Ã¸®¾ó¸ð´ÏÅÍ</div><div> Blue.begin(9600); //ºí·çÅõ½º ½Ã¸®¾ó</div><div> Wire.begin();</div><div> RTC.begin();</div><div><br></div><div>#if defined (__AVR_ATtiny85__)</div><div> if (F_CPU == 16000000) clock_prescale_set(clock_div_1);</div><div>#endif</div><div> strip.begin();</div><div> strip.show(); // Initialize all pixels to 'off'</div><div><br></div><div> lcd.begin(16, 2); // LCDÀÇ Å©±â¸¦ ¼³Á¤ÇÑ´Ù.</div><div> analogWrite(10, 120);</div><div> lcd.print("hello, world!");</div><div> delay(500);</div><div> lcd.clear();</div><div>}</div><div><br></div><div>int command[10];</div><div>char resend[30] = {'\0'};</div><div>int aram_h;</div><div>int aram_m;</div><div>//////////////////////////////////////////////////////////////////////////////</div><div>void loop() {</div><div><br></div><div> get_command();</div><div><br></div><div> //1: ºû »ö±ò ºñ²Ù±â</div><div> if (command[0] == 1) {</div><div> colorWipe(strip.Color(command[1], command[2], command[3]), 0);</div><div> initial_command();</div><div> }</div><div> // 2: »óÅ¿¡ ´ëÇÑ ÀÀ´ä</div><div> else if (command[0] == 2) {</div><div> resend_state();</div><div> initial_command();</div><div> }</div><div> //3: ¾Ë¶÷¼³Á¤</div><div> else if (command[0] == 3) {</div><div> set_aram();</div><div> resend_aram();</div><div> initial_command();</div><div> }</div><div> //4: ½Ã°£µ¿±âÈ</div><div> else if (command[0] == 4) {</div><div> set_time();</div><div> resend_time();</div><div> initial_command();</div><div> }</div><div> //5 : ºû ¹à±â Á¶Àý</div><div> else if (command[0] == 5) {</div><div> if (command[1] == 0)</div><div> command[1] = 500;</div><div> strip.setBrightness(command[1]);</div><div> initial_command();</div><div> }</div><div><br></div><div> DateTime now = RTC.now();</div><div> if (aram_h == now.hour() && aram_m == now.minute()) {</div><div> Serial.print("wef");</div><div> rainbow(20);</div><div> }</div><div><br></div><div>}</div><div>//////////////////////////////////////////////////////////////////////////////</div><div>void get_command() {</div><div> char arr[25] = {'\0'};</div><div> char *tmp;</div><div> int i = 0;</div><div> int j = 0;</div><div><br></div><div> while (Blue.available()) {</div><div> char myChar = (char)Blue.read();</div><div> arr[i++] += myChar;</div><div> delay(10);</div><div> }</div><div><br></div><div> if (arr[0]) {</div><div> tmp = strtok(arr, "/");</div><div> while (tmp != NULL) {</div><div> command[j++] = atoi(tmp);</div><div> tmp = strtok(NULL, "/");</div><div> }</div><div> }</div><div><br></div><div> for (int k = 0; k < j; k++) {</div><div> Serial.println(command[k]);</div><div> }</div><div>}</div><div><br></div><div>void initial_command() {</div><div> for (int i = 0; i < 10; i++)</div><div> command[i] = 0;</div><div>}</div><div><br></div><div>uint32_t Wheel(byte WheelPos) {</div><div> WheelPos = 255 - WheelPos;</div><div> if (WheelPos < 85) {</div><div> return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);</div><div> }</div><div> if (WheelPos < 170) {</div><div> WheelPos -= 85;</div><div> return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);</div><div> }</div><div> WheelPos -= 170;</div><div> return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);</div><div>}</div><div><br></div><div>void rainbow(uint8_t wait) {</div><div> uint16_t i, j;</div><div><br></div><div> for (j = 0; j < 256; j++) {</div><div> for (i = 0; i < strip.numPixels(); i++) {</div><div> strip.setPixelColor(i, Wheel((i + j) & 255));</div><div> }</div><div> strip.show();</div><div> delay(wait);</div><div> }</div><div>}</div><div><br></div><div>void colorWipe(uint32_t c, uint8_t wait) {</div><div> for (uint16_t i = 0; i < strip.numPixels(); i++) {</div><div> strip.setPixelColor(i, c);</div><div> strip.show();</div><div> delay(wait);</div><div> }</div><div>}</div><div>void set_aram(){</div><div> aram_h=command[1];</div><div> aram_m=command[2];</div><div>}</div><div><br></div><div>void resend_aram(){</div><div> char tmp[5] = {0};</div><div> </div><div> strcpy(resend, "3/");</div><div> itoa(aram_h, tmp, 10);</div><div> strcat(resend, tmp);</div><div> strcat(resend, "/");</div><div> itoa(aram_m, tmp, 10);</div><div> strcat(resend, tmp);</div><div> strcat(resend, "\n");</div><div><br></div><div> Blue.write(resend);</div><div>}</div><div><br></div><div>char *char_month[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",</div><div> "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"</div><div> };</div><div>void set_time() {</div><div> char date_data[11] = {'\0'};</div><div> char time_data[8] = {'\0'};</div><div> char tmp[5] = {0};</div><div><br></div><div> strcpy(date_data, char_month[command[2] - 1]);</div><div> strcat(date_data, " ");</div><div> itoa(command[3], tmp, 10);</div><div> strcat(date_data, tmp);</div><div> strcat(date_data, " ");</div><div> itoa(command[1], tmp, 10);</div><div> strcat(date_data, tmp);</div><div><br></div><div> itoa(command[4], tmp, 10);</div><div> strcpy(time_data, tmp);</div><div> strcat(time_data, ":");</div><div> itoa(command[5], tmp, 10);</div><div> strcat(time_data, tmp);</div><div> strcat(time_data, ":");</div><div> itoa(command[6], tmp, 10);</div><div> strcat(time_data, tmp);</div><div><br></div><div> RTC.adjust(DateTime(date_data, time_data));</div><div>}</div><div><br></div><div>void resend_time() {</div><div> DateTime now = RTC.now();</div><div> char tmp[5] = {0};</div><div> strcpy(resend, "4/");</div><div> itoa(now.year(), tmp, 10);</div><div> strcat(resend, tmp);</div><div> strcat(resend, "/");</div><div> itoa(now.month(), tmp, 10);</div><div> strcat(resend, tmp);</div><div> strcat(resend, "/");</div><div> itoa(now.day(), tmp, 10);</div><div> strcat(resend, tmp);</div><div> strcat(resend, "/");</div><div> itoa(now.hour(), tmp, 10);</div><div> strcat(resend, tmp);</div><div> strcat(resend, "/");</div><div> itoa(now.minute(), tmp, 10);</div><div> strcat(resend, tmp);</div><div> strcat(resend, "/");</div><div> itoa(now.second(), tmp, 10);</div><div> strcat(resend, tmp);</div><div> strcat(resend, "\n");</div><div><br></div><div> Blue.write(resend);</div><div>}</div><div><br></div><div><br></div><div>void resend_state() {</div><div> // ½Ã°£ºÎºÐ</div><div> DateTime now = RTC.now();</div><div> char tmp[5] = {0};</div><div> strcpy(resend, "2/");</div><div> itoa(now.year(), tmp, 10);</div><div> strcat(resend, tmp);</div><div> strcat(resend, "/");</div><div> itoa(now.month(), tmp, 10);</div><div> strcat(resend, tmp);</div><div> strcat(resend, "/");</div><div> itoa(now.day(), tmp, 10);</div><div> strcat(resend, tmp);</div><div> strcat(resend, "/");</div><div> itoa(now.hour(), tmp, 10);</div><div> strcat(resend, tmp);</div><div> strcat(resend, "/");</div><div> itoa(now.minute(), tmp, 10);</div><div> strcat(resend, tmp);</div><div> strcat(resend, "/");</div><div> itoa(now.second(), tmp, 10);</div><div> strcat(resend, tmp);</div><div> // ¹à±â ºÎºÐ</div><div> lightLevel = analogRead(sensorPin);</div><div> lightLevel = map(lightLevel, 500, 1023, 0, 255);</div><div> lightLevel = constrain(lightLevel, 0, 255);</div><div> strcat(resend, "/");</div><div> itoa(lightLevel, tmp, 10);</div><div> strcat(resend, tmp);</div><div><br></div><div> //¿Â½Àµµ ºÎºÐ</div><div> float temp, humi;</div><div> dht11.read(humi, temp);</div><div> strcat(resend, "/");</div><div> itoa((int)temp, tmp, 10);</div><div> strcat(resend, tmp);</div><div> strcat(resend, "/");</div><div> itoa((int)humi, tmp, 10);</div><div> strcat(resend, tmp);</div><div><br></div><div> strcat(resend, "\n");</div><div> Blue.write(resend);</div><div>}</div><div><br></div><div>´ÜÀÚ»çÁø</div><div><img onLoad='miniSelfResize(contents_3941,this); if(this.parentNode.tagName=="A"){this.onclick = "";}' src="/shop/lib/meditor/../../data/editor/e583fafc5eecddc3.jpg"></div><div><br></div><div><img onLoad='miniSelfResize(contents_3941,this); if(this.parentNode.tagName=="A"){this.onclick = "";}' src="/shop/lib/meditor/../../data/editor/9aaf9fb2d402ea64.jpg"><br></div><div><br></div><div>»çÁø¿¡ º¸½Ã´Ù½ÃÇÇ LED°¡ 6°³¸¸ µé¾î¿É´Ï´Ù.</div></b></span></div>