ใบพัดนาฬิกา POV บอกเวลาควบคุมด้วย Arduino



Project

เครื่องบอกเวลา  POV

 

บทนำ

แนวคิดที่มาและความสำคัญ

ปัจจุบัน เทคโนโลยีมีความสำคัญต่อการดำรงชีวิตของมนุษย์ เราเป็นอย่าง เช่น การใช้โทรศัพท์ โทรทัศน์ และ อื่่นๆ ซึ่งเราอาจไม่รู้ตัวว่าเทคโนโลยีมีความสำคัญขนาดใหนกับการใช้ชีวิตความสะดวกสบายในการ ทำงาน หรือ การมีความคิดสร้างสรรค์ในการเอาเทคโนโลยีมา รวมกัน ซึ่งให้ได้สิ่งใหม่ๆออกมา เพื่อให้มีประสิทธิภาพมากยิ่งขึ้นและสะดวกสบายมากขึ้นที่มาของ Project คือ ได้แนวคิดจากการ นำใบพัดมาประยุกต์ใช้กับเครื่องบอกเวลา เพื่อให้ได้เครื่องบอกเวลาที่ดูสวยงามและดูแปลกตาซึ่ง เราสามารถใช้รีโมต ในการควบคุมเวลา และวันได้

วัตถุประสงค์

เพื่อให้ มีความสะดวก ในการดูเวลา และ  ใช้ในการตกแต่งเพื่อความ

อุปกรณ์

1.LED 5 mm

2.ตัวต้านทาน 220โอห์ม

3.ตัวต้านทาน 10k  โอห์ม

4.เซนเซอร์ แสง infrared

5.ตัวรับอินฟาเรต รีโมท

6.capacitor 470 uF

7.IC 7805 1.5 A

8.74HC595

9.Arduino nano

10.RTC ds3231 IC Time
11.รางถ่าน

12.แหล่งจ่ายไฟ 12V 2A

13.แจ็คตัวเมีย

14.ชุดรีโมท

15.มอเตอร์พร้อมหัว

16.แผ่น PCBที่กัดเสร็จแล้ว

 

Arduino nano

Arduino คือ บอร์ดไมโครคอนโทรลเลอร์สำเร็จรูป ที่รวมเอาตัวไมโครคอนโทรลเลอร์และอุปกรณ์อื่นๆที่จำเป็น มาในบอร์ดเดียว แถมยังเปิดเผยข้อมูลทุกๆอย่าง ทั้งลายวงจรและตัวอย่างโปรแกรม ทำให้ผู้ใช้สามารถนำไปพัฒนาต่อได้ง่าย เพียงแค่เรามีบอร์ด Arduino กับคอมพิวเตอร์อีกซักเครื่อง ก็พร้อมใช้งานได้แล้ว โดยที่ไม่ต้องมาปวดหัว กับการทำวงจรที่ซับซ้อน หรือการติดตั้งโปรแกรมที่ยุ่งยาก

โดยทาง Arduino ได้ผลิตบอร์ดสำเร็จรูปออกมาหลายรุ่น หลายขนาด โดยแต่ละรุ่นก็มีข้อดีแตกต่างกันออกไป แต่รุ่นที่เราจะมาแนะนำกันในวันนี้คือ  Arduino nano ซึ่งเป็นรุ่นที่มีขนาดเล็ก เหมาะสำหรับผู้ที่ต้องการเริ่มต้นเขียนโปรแกรมบนไมโครคอนโทรลเลอร์ เพื่อศึกษา หรือเพื่อนำมาประยุกต์ใช้สร้างงานอดิเรกง่ายๆ

Arduino nano มีขนาดเพียง 1.8 x 4.8 เซนติเมตร หรือมีขนาดประมาณนิ้วหัวแม่มือของเรา ซึ่งถือว่ามีขนาดเล็กมาก เมื่อเทียบกับบอร์ดไมโครคอนโทรลเลอร์อื่น บนบอร์ด Arduino nano นั้นมีวงจรสำหรับปรับแรงดันไฟฟ้าให้เหมาะสมกับตัวมันเองอยู่แล้ว เพียงแค่เราเสียบสาย USB เข้ากับ Arduino nano และต่อเข้ากับคอมพิวเตอร์ บอร์ดก็พร้อมใช้งานได้ทันที



RCT ds3231 IC Timer

DS3231 เป็นโมดูลนาฬิกาแบบเวลาจริง RTC Real Time Clock ทำให้เราสามารถเพิ่มวงจรนาฬิกาให้กับ Arduino ของเราได้ โมดูล DS3231 นี้มาพร้อมกับ IC EEPROM AT24C32 ทำให้มีพื้นที่ในการเก็บข้อมูลที่เราต้องการ เช่น การตั้งค่าต่าง ๆ ได้ โมดูล DS3231 มีความถูกต้องแม่นยำสูง เพราะข้างในยังมี วงจรวัดอุณหภูมิ เพื่อนำไปคำนวนปรับค่าเวลาให้ถูกต้องในวงจร ทำให้โมดูลนี้ มีความสามารถเป็น นาฬิกา RTC , หน่วยความจำ EEPROM สำหรับเก็บข้อมูล และ มีเซนเซอร์อุณหภูมิมาให้ด้วย มาพร้อมแบตสำรอง ทำให้ทำงานได้แม้บอร์ด Arduino จะถูกปิดไปแล้ว

 รูปแผงวงจรด้านหน้า



รูปแผงวงจรด้านหลัง


รูปแผงภายในกล่อง

 

 

โค้ดที่ใช้ในการควบคุม

#include <IRremote.h>

int RECV_PIN = 7;

IRrecv irrecv(RECV_PIN);

decode_results results;

#include <DS3231.h>

DS3231  rtc(SDA, SCL);

// Init a Time-data structure

Time  t;

/********************************************************************************************/

unsigned char txt_p[2][6] ={ B11111110, B11111111, B01100011, B01100011, B01111111, B00111110,

B11111000, B11111000, B00000000, B00000000, B00000000, B00000000 };

unsigned char txt_o[2][6] ={ B11111110, B11111111, B00000011, B00000011, B11111111, B11111110,

B11110000, B11111000, B00011000, B00011000, B11111000, B11110000};

unsigned char txt_v[2][7] ={ B01111111, B11111100, B00000000, B00000000, B00000000, B11111100, B01111111,

B00000000, B11100000, B11111000, B00011000, B11111000, B11100000, B00000000};

unsigned char txt_b[2][6] ={B11111111, B11111111, B01100011, B01100011, B11111110, B00011100,

B11111000, B11111000, B00011000, B00011000, B11110000, B11100000 };

unsigned char txt_y[2][6] ={B01111111, B11111100, B11000000, B11000000, B11111100, B01111111,

B00000000, B11111000, B11111000, B11111000, B10000000, B00000000 };

unsigned char txt_m[2][9] ={B11111111, B11111110, B00011100, B00111000, B11110000, B00111000, B00011100, B11111110, B11111111,

B11111000, B11110000, B00000000, B00000000, B00000000, B00000000, B00000000, B11100000, B11111000};

unsigned char txt_a[2][9] ={B10000000, B11100000, B11111000, B10011110, B10000111, B10011110, B11111000, B11100000, B10000000,

B11111000, B11110000, B10000000, B10000000, B10000000, B10000000, B10000000, B11110000, B11111000};

unsigned char txt_x[2][9] ={B00000111, B00001110, B10011100, B11111000, B11110000, B11111000, B10011100, B00001110, B00000111,

B00111000, B01110000, B11100000, B10000000, B00000000, B10000000, B11100000, B01110000, B00111000 };

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

unsigned char number[10][5] = { B00111110, B01000001, B01000001, B00111110, B00000000, //0

B01000010, B01111111, B01000000, B00000000, B00000000, //1

B01100010, B01010001, B01001001, B01000110, B00000000, //2

B00100010, B01001001, B01001001, B00110110, B00000000, //3

B00011000, B00010100, B00010010, B01111111, B00000000, //4

B00100111, B01000101, B01000101, B00111001, B00000000, //5

B00111110, B01001001, B01001001, B00110001, B00000000, //6

B01100001, B00011001, B00000101, B00000011, B00000000, //7

B00110110, B01001001, B01001001, B00110110, B00000000, //8

B01000110, B01001001, B01001001, B00111110, B00000000, //9

};

unsigned char  sy[3] = {B00000000, B01100110, B00000000 };

unsigned char  sy2[3]={ B00001000, B00001000, B00001000 };

unsigned char  sy3[4]={ B00011000, B00100100, B01000010, B10000001};

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

unsigned char setting[4][5] = {B01000110, B10001001, B10001001, B10010001, B01110010,   //s

B11111111, B10001001, B10001001, B10001001, B10000001,  // e

B00000001, B00000001, B11111111, B00000001, B00000001, // t

B01111110, B10000001, B10110001, B10010001, B01100010 }; //g

unsigned char setting_i[3] =  {B10000001, B11111111, B10000001 }; // i

unsigned char setting_n[6] =  {B11111111, B00000100, B00001000, B00010000, B00100000,  B11111111};

unsigned char setting_n2[6] =  {B11111111, B00000100, B00001000, B00010000, B11111111};

unsigned char setting_m[8] =  {B1111111,  B00000100, B00011000, B00100000, B00100000, B00011000, B00000100, B11111111};

unsigned char setting_m2[6] =  {B1111111, B00011000, B00100000, B00100000, B00011000, B11111111};

unsigned char setting_da[2][5]=   {B11111111, B10000001, B10000001, B01000010, B00111100,

B11111100, B00100010, B00100001, B00100010, B11111100 };

unsigned char setting_h[5] = {B11111111, B00011000, B00011000, B00011000, B11111111 };

unsigned char setting_o[5] = {B01111110, B10000001, B10000001, B10000001, B01111110};

unsigned char setting_u[5] = {B01111111, B10000000, B10000000, B10000000, B01111111};

unsigned char setting_r[5] = {B11111111, B00010001, B00010001, B01101001, B10000110 };

unsigned char setting_c[5] = {B00111100, B01000010, B10000001, B10000001, B01000010 };

unsigned char setting_y[5] = {B00000111, B00001000, B11110000, B00001000, B00000111 };

//Pin connected to ST_CP 12 of 74HC595

int latchPin = 9;

//Pin connected to SH_CP  11 of 74HC595

int clockPin = 10;

////Pin connected to DS of 14 74HC595 1

int dataPin = 8;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void setup() {

pinMode(latchPin, OUTPUT);

pinMode(dataPin, OUTPUT);

pinMode(clockPin, OUTPUT);

irrecv.enableIRIn();

pinMode(13, OUTPUT);

rtc.begin();

Serial.begin(9600);

Serial.print(“OK”);

// rtc.setTime(6, 30, 0);  //ตังชั่วโมง นาที วินาที

//rtc.setDate(6, 8, 2018); //ตังวันที่ เดือน ปี

}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

unsigned char h ;

unsigned char hh ;

unsigned char m ;

unsigned char mm ;

unsigned char s ;

unsigned char ss ;

unsigned char da ;

unsigned char daa ;

unsigned char mo ;

unsigned char moo ;

unsigned char y ;

unsigned char yy ;

unsigned char yyy ;

unsigned char yyyy ;

int d = 80 ;//แก้ยืดเวลา

int dd = (200/2)- (200/4) ;

int d3 = 22  ;  //แก้ยืดวันที่

int d4 = 7 ; //ความห่างของเวลากับวันที่

int d6 = 14 ; //เว้นวรรคหลัง Setting

int d7 = 1000 ; // ระยะหลังคำว่า year mout day

int d8 = 13 ;// ระยะหลังคำว่า hour min sec

int d2 = (1500/2)- (1500/4) ;

int ds = 9 ;

int ds2 = 8 ;

int ds_2 = 4 ;

int d_n = 1 ;

int pwm = 0 ;

int val ;

boolean tf = 1 ;

boolean tf_menu = 0 ;

boolean tf_menu1 = 0 ;

boolean tf_menu2 = 0 ;

boolean tf_menu3 = 0 ;

boolean tf1 = 1 ;  //time

boolean tf2 = 0 ; // date

boolean st1 = 0 ;

unsigned char st_hms = 1 ;

boolean st_setting = 1 ;

/////////////////////////////////////////////////////////////////////////////////////////

void loop () {

val = analogRead(A0) ;

if(val < 750 ){

if(tf_menu == 0 ){

tf1 = 1 ;

tf2 = 1 ;

timer () ;

if ( irrecv.decode(&results)) {

 

if(results.value == 0xFF6897){  // menu *

tf_menu = 1 ;

tf_menu2 = 1 ;

 

tf_menu1 = 0 ;

tf_menu3 = 0 ;

}

irrecv.resume();

}

}

if(tf_menu == 1) {

 

if(tf_menu1 == 1){

set_time_t ();

}

if(tf_menu3 == 1){

set_time_d ();

}

if(tf_menu2 == 1){

set_time () ;

}

}

 

 

 

}

 

}

 

void set_time_d(){

tf1 = 0 ; //time

tf2 = 1 ; // date

for(int i = 0 ; i < 4 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   sy3[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // >

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds2+10);

////////////////////////////////////////////////////////////////////

 

if(st_hms == 1){

delayMicroseconds(2000);

for(int i = 0 ; i < 5  ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, LSBFIRST,   setting_da[0][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                              //d

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

for(int i = 0 ; i < 5  ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting_da[1][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                              //a

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

for(int i = 0 ; i < 5  ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting_y[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                              //y

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(1800);

}

 

if(st_hms == 2){

for(int i = 0 ; i < 6 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting_m2[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d_n);                          // m2

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

for(int i = 0 ; i < 5  ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, LSBFIRST,   setting_o[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds_2);                              //o

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds_2);

for(int i = 0 ; i < 5 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting_n2[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d_n);                          // n

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds_2);

 

for(int i = 0 ; i < 5  ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting[2][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds_2);                              //t

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds_2);

for(int i = 0 ; i < 5  ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting_h[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds_2);                              //h

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds_2);

}

 

if(st_hms == 3){

delayMicroseconds(700);

for(int i = 0 ; i < 5  ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting_y[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                              //y

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

for(int i = 0 ; i < 5  ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting[1][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                              //e

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

for(int i = 0 ; i < 5  ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting_da[1][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                              //a

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

for(int i = 0 ; i < 5  ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting_r[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                              //r

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(900);

}

///////////

for(int i = 3 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   sy3[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // <

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d7);

/////////

timer();

//////////

if ( irrecv.decode(&results)) {

 

 

if(results.value == 0xFF10EF){  // < ปุ่ม ลูกศรซ้าย

if(st_hms == 1 ){

st_hms = 3 ;

}else{

st_hms — ;

}

 

 

}

if(results.value == 0xFF5AA5){ //>  ปุ่ม ลูกศรขวา

if(st_hms == 3 ){

st_hms = 1 ;

}else{

st_hms ++ ;

}

}

if(results.value == 0xFF18E7)

{                              //up  ปุ่ม ลูกศรขึ้น

if(st_hms == 1 )

{

if(t.date == 31){rtc.setDate(1, t.mon, t.year);}

else{ rtc.setDate(t.date+1, t.mon, t.year);

}

 

}

 

 

if(st_hms == 2 )

{

if(t.mon == 12){rtc.setDate(t.date, 1, t.year);}

else{ rtc.setDate(t.date, t.mon+1, t.year);

}

 

}

 

if(st_hms == 3 )

{

rtc.setDate(t.date, t.mon, t.year+1);

 

}

 

}

if(results.value == 0xFF4AB5)

{                                 //down ปุ่ม ลูกศรลง

if(st_hms == 1 )

{

if(t.date == 1){rtc.setDate(31, t.mon, t.year);}

else{ rtc.setDate(t.date-1, t.mon, t.year);

}

 

}

 

 

if(st_hms == 2 )

{

if(t.mon == 1){rtc.setDate(t.date, 12, t.year);}

else{ rtc.setDate(t.date, t.mon-1, t.year);

}

 

}

 

if(st_hms == 3 )

{

rtc.setDate(t.date, t.mon, t.year-1);

}

 

}

if(results.value == 0xFF38C7){  //ok ปุ่ม ตกลง

tf_menu = 0 ;

tf_menu1 = 0 ;

tf_menu2 = 0 ;

tf_menu3 = 0 ;

}

if(results.value == 0xFF6897){  //menu ปุ่ม *

tf_menu = 0 ;

tf_menu1 = 0 ;

tf_menu2 = 0 ;

tf_menu3 = 0 ;

}

if(results.value == 0xFFB04F){ //exit  ปุ่มออก

tf_menu = 1 ;

tf_menu2 = 1 ;

tf_menu1 = 0 ;

tf_menu3 = 0 ;   }

irrecv.resume();    }

}

////////////////////////////////////////////////////////////

void set_time_t(){

tf1 = 1 ; //time

tf2 = 0 ; // date

timer ();

delay(d8);

for(int i = 0 ; i < 4 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   sy3[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // >

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds2+10);

////////////////////////////////////////////////////////////////////

 

if(st_hms == 1 ){

for(int i = 4 ; i >= 0  ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, LSBFIRST,   setting_r[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                              //r

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

for(int i = 0 ; i < 5  ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, LSBFIRST,   setting_u[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                              //u

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

for(int i = 0 ; i < 5  ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting_o[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                              //o

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

for(int i = 0 ; i < 5  ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting_h[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                              //h

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(500);

}

if(st_hms == 2){

delayMicroseconds(900);

for(int i = 0 ; i < 6 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting_n[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d_n);                          // n

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

 

for(int i = 0 ; i < 3 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting_i[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // i

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);

for(int i = 0 ; i < 8 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, LSBFIRST,   setting_m[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d_n);                          // m

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(900);

 

}

if(st_hms == 3){

delayMicroseconds(1400);

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, LSBFIRST,   setting_c[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // c

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds2);

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, LSBFIRST,   setting[1][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // e

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds2);

for(int i = 0 ; i < 5  ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting[0][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                              //s

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(1400);

 

}

//////////////////////////////////////////////////////////////////

for(int i = 3 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   sy3[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // <

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

 

if ( irrecv.decode(&results)) {

 

 

if(results.value == 0xFF10EF){  // ซ้าย <

if(st_hms == 1 ){

st_hms = 3 ;

}else{

st_hms — ;

}

 

 

}

if(results.value == 0xFF5AA5){ //ขวา >

if(st_hms == 3 ){

st_hms = 1 ;

}else{

st_hms ++ ;

}

}

if(results.value == 0xFF18E7)

{                                 //ขึ้นup

if(st_hms == 1 )

{

if(t.hour == 23){rtc.setTime(0, t.min, t.sec);}

else{ rtc.setTime(t.hour+1, t.min, t.min);

}

 

}

 

 

if(st_hms == 2 )

{

if(t.min == 59){rtc.setTime(t.hour, 0, t.sec);}

else{ rtc.setTime(t.hour, t.min+1, t.sec);

}

 

}

 

if(st_hms == 3 )

{

if(t.sec == 59){rtc.setTime(t.hour, t.min, 0);}

else{ rtc.setTime(t.hour, t.min, t.sec+1);

}

 

}

}

if(results.value == 0xFF4AB5)

{                                 // ลง down

if(st_hms == 1 )

{

if(t.hour == 0){rtc.setTime(23, t.min, t.sec);}

else{ rtc.setTime(t.hour-1, t.min, t.min);

}

 

}

 

 

if(st_hms == 2 )

{

if(t.min == 0){rtc.setTime(t.hour, 59, t.sec);}

else{ rtc.setTime(t.hour, t.min-1, t.sec);

}

 

}

 

if(st_hms == 3 )

{

if(t.sec == 0){rtc.setTime(t.hour, t.min, 59);}

else{ rtc.setTime(t.hour, t.min, t.sec-1);

}

 

}

}

if(results.value == 0xFF38C7){  //ok

tf_menu = 0 ;

tf_menu1 = 0 ;

tf_menu2 = 0 ;

tf_menu3 = 0 ;

}

 

if(results.value == 0xFF6897){  //menu

tf_menu = 0 ;

tf_menu1 = 0 ;

tf_menu2 = 0 ;

tf_menu3 = 0 ;

}

if(results.value == 0xFFB04F){ //exit

tf_menu = 1 ;

tf_menu2 = 1 ;

tf_menu1 = 0 ;

tf_menu3 = 0 ;   }

irrecv.resume();    }

}

////////////////////////////////////////////////////////////////////////////////////

void set_time(){

 

for(int i = 0 ; i < 5  ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting[0][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                              //s

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds2);

 

for(int i = 0 ; i < 5 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting[1][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // e

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds2);

 

for(int i = 0 ; i < 5 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting[2][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // t

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds2);

 

for(int i = 0 ; i < 5 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting[2][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // t

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds2);

 

for(int i = 0 ; i < 3 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting_i[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // i

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);

for(int i = 0 ; i < 6 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting_n[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d_n);                          // n

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

 

for(int i = 0 ; i < 5 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting[3][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // g

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delay(d6);

 

////////////////////////////////////////////////////////////////////////

for(int i = 0 ; i < 4 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   sy3[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // >

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds2+10);

//////////////////////////////////////////////////////////////////////////////

if(st1 == 0){

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting[1][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // e

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds2);

for(int i = 0 ; i < 8 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, LSBFIRST,   setting_m[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d_n);                          // m

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

for(int i = 0 ; i < 3 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, LSBFIRST,   setting_i[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // i

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, LSBFIRST,   setting[2][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // t

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

 

}

if(st1 == 1){

delayMicroseconds(400);

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   setting[1][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // e

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds2);

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, LSBFIRST,   setting[2][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // t

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, LSBFIRST,   setting_da[1][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // a

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, LSBFIRST,   setting_da[0][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // d

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds2+400);

 

}

///////////////////////////////////////////////////////////////////////////////////////////

 

for(int i = 3 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,   B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,   sy3[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(ds);                          // <

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

 

if ( irrecv.decode(&results)) {

 

if(results.value == 0xFF10EF){  //<

st1 = !st1 ;

}

if(results.value == 0xFF5AA5){  //>

st1 = !st1 ;

}

 

if(results.value == 0xFF6897){ //menu

tf_menu = !tf_menu ;

 

}

if(results.value == 0xFFB04F){ //Exit

tf_menu = 0 ;

tf_menu2 = 0 ;

}

if(results.value == 0xFF38C7){ // ok

if(st1 == 0){tf_menu = 1 ;

tf_menu1 = 1 ;    // timer

tf_menu3 = 0 ;

tf_menu2 = 0 ;

}

if(st1 == 1){ tf_menu = 1 ;  //date

tf_menu3 = 1 ;

tf_menu1 = 0 ;

tf_menu2 = 0 ;

}

}

 

irrecv.resume();    }

}

 

 

void title() {

 

 

if( pwm <= 85){

 

for(int i = 0 ; i <6 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  txt_p[1][i]);

shiftOut(dataPin, clockPin, MSBFIRST,   txt_p[0][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(dd);

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

 

for(int i = 0 ; i <6 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  txt_o[1][i]);

shiftOut(dataPin, clockPin, MSBFIRST,   txt_o[0][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(dd);

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

for(int i = 0 ; i <7 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  txt_v[1][i]);

shiftOut(dataPin, clockPin, MSBFIRST,   txt_v[0][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(dd);

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delay(15);

for(int i = 8 ; i >=0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  txt_x[0][i]<<1);

shiftOut(dataPin, clockPin, MSBFIRST,   txt_x[1][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d);

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

for(int i = 8 ; i >=0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  txt_a[0][i]<<1);

shiftOut(dataPin, clockPin, MSBFIRST,   txt_a[1][i]

);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d);

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

for(int i = 8 ; i >=0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  txt_m[0][i]<<1);

shiftOut(dataPin, clockPin, MSBFIRST,   txt_m[1][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d);

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

}

///////////////////////////////////////////////////////////////////////////////////

if(pwm > 85 ){

delay (3);

for(int i = 0 ; i <6 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, txt_b[1][i]);

shiftOut(dataPin, clockPin, MSBFIRST,   txt_b[0][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(dd+50);

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

 

for(int i = 0 ; i <6 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  txt_y[1][i]);

shiftOut(dataPin, clockPin, MSBFIRST,   txt_y[0][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(dd);

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delay(17);

for(int i = 8 ; i >=0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  txt_x[0][i]<<1);

shiftOut(dataPin, clockPin, MSBFIRST,   txt_x[1][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d);

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

 

for(int i = 8 ; i >=0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  txt_a[0][i]<<1);

shiftOut(dataPin, clockPin, MSBFIRST,   txt_a[1][i]

);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d);

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d2);

for(int i = 8 ; i >=0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  txt_m[0][i]<<1);

shiftOut(dataPin, clockPin, MSBFIRST,   txt_m[1][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d);

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

}

if (pwm > 175 ){ tf = 1 ;}

pwm ++ ;

}

///////////////////////////////////////////////////////////////////////////////////////////

void timer() {

if(tf1 == 1){

t = rtc.getTime();

h = t.hour/10 ;

hh = t.hour-(h*10) ;

m = t.min/10 ;

mm = t.min-(m*10) ;

s = t.sec/10 ;

ss = t.sec-(s*10) ;

////////////////////////////////////

for(int i = 0 ; i <= 4 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  number[h][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d);

}

for(int i = 0 ; i <= 4 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  number[hh][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d);

}

for(int i = 0 ; i < 3 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  sy[i]);

digitalWrite(latchPin, HIGH);

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

 

for(int i = 0 ; i <= 4 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  number[m][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d);

}

for(int i = 0 ; i <= 4 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  number[mm][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d);

}

 

for(int i = 0 ; i < 3 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  sy[i]);

digitalWrite(latchPin, HIGH);

}

delayMicroseconds(d);

 

for(int i = 0 ; i <= 4 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  number[s][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d);

}

for(int i = 0 ; i <= 4 ; i ++){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  number[ss][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d);

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

}

//////////////////////////////////////////////

if(tf2 == 1 ){

t = rtc.getTime();

da = t.date/10 ;

daa =t.date-(da*10) ;

mo = t.mon/10 ;

moo = t.mon-(mo*10) ;

 

y = t.year/1000 ;

yy = (t.year-(y*1000))/100 ;

yyy = (t.year-(yy*100)-(y*1000))/10 ;

yyyy = t.year-((t.year/10)*10) ;

delay(d4);

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  0);

shiftOut(dataPin, clockPin, LSBFIRST,  number[yyyy][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d3);

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  0);

shiftOut(dataPin, clockPin, LSBFIRST,  number[yyy][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d3);

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  0);

shiftOut(dataPin, clockPin, LSBFIRST,  number[yy][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d3);

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

 

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  0);

shiftOut(dataPin, clockPin, LSBFIRST,  number[y][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d3);

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(300);

for(int i = 2 ; i >=0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,  0);

shiftOut(dataPin, clockPin, MSBFIRST,  sy2[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d3);

}

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  0);

shiftOut(dataPin, clockPin, LSBFIRST,  number[moo][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d3);

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  0);

shiftOut(dataPin, clockPin, LSBFIRST,  number[mo][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d3);

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

delayMicroseconds(300);

 

for(int i = 2 ; i >=0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST,  0);

shiftOut(dataPin, clockPin, MSBFIRST,  sy2[i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d3);

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

 

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  0);

shiftOut(dataPin, clockPin, LSBFIRST,  number[daa][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d3);

}

 

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

 

for(int i = 4 ; i >= 0 ; i –){

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  0);

shiftOut(dataPin, clockPin, LSBFIRST,  number[da][i]);

digitalWrite(latchPin, HIGH);

delayMicroseconds(d3);

}

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

shiftOut(dataPin, clockPin, MSBFIRST,  B00000000);

digitalWrite(latchPin, HIGH);

}

}



ที่มาของโค้ด

https://www.youtube.com/redirect?event=video_description&v=HzMsxLVl9iQ&redir_token=eYA6qqCs-i-PpHDvrMjgOE9eaeZ8MTU1Nzg1MTAxOUAxNTU3NzY0NjE5&q=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F0By3TaYzuwS2qRy1hNnFIV0t0dHc%2Fview%3Fusp%3Dsharing

 

ข้อจำกัดของโครงงาน

ตอนนี้โครงงานยังมีข้อจำกัดคือการเลือกข้อความใส่ไม่ได้และยังมีความหลากหลายที่น้อยซึ่งต้องนำไปพัฒนาให้มีความซับซ้อนที่มากขึ้น

แนวทางการพัฒนา

ในอนาคตอาจจะพัฒนาให้มีความหลากหลายมากขึ้น เช่น ใส่ข้อความหรือ แสดงรูปแบบต่างที่ซับซ้อนขึ้นกว่าเดิม

 

แหล่งที่มาอ้างอิง

https://www.youtube.com/watch?v=HzMsxLVl9iQ&t=16s&fbclid=IwAR2eknzNn63U67H7Ni0XL2Od7di821qrmEdlwVwnhwPVir-99s0QFGASjdk

DIY

https://youtu.be/BhkYSnCAKDo

การนำเสนอโครงงาน

https://youtu.be/ivBBgMKkHlk



at GlurGeek.Com
เป็นนักศึกษา ม.กรุงเทพ คณะวิศวกรรมศาศาสตร์

Leave a Reply

© 2022 GlurGeek.Com
Exit mobile version