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
#define Num_Of_Word 100 | |
PROGMEM const unsigned char Word[Num_Of_Word][32] = | |
{ | |
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, | |
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, //Spec | |
0XFF,0XC3,0XC3,0XC3,0XC3,0XC3,0XE7,0XE7,0XE7,0XE7,0XE7,0XE7,0XFF,0XE7,0XE7,0XFF, | |
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, //! | |
0XFF,0XCE,0XE7,0XF3,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, | |
0XFF,0X7F,0X3F,0X9F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, //" | |
0XFF,0XF3,0XF3,0XC0,0XC0,0XF3,0XF3,0XF3,0XF3,0XF3,0XF3,0XC0,0XC0,0XF3,0XF3,0XFF, |
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
void setup() | |
{ | |
SPI.begin(); //ประกาศการใช้งาน SPI | |
SPI.setBitOrder( LSBFIRST ); //ใช้งานในโหมด Least Significant Bit First | |
SPI.setClockDivider( SPI_CLOCK_DIV2 );// 16MHz/16 -> 1MHz SCK frequency | |
SPI.setDataMode( SPI_MODE0 ); // use SPI mode 0 | |
pinMode(LEDARRAY_D, OUTPUT); //กำหนด Pin ให้อยู่ในโหมด Output | |
pinMode(LEDARRAY_C, OUTPUT); //กำหนด Pin ให้อยู่ในโหมด Output | |
pinMode(LEDARRAY_B, OUTPUT); //กำหนด Pin ให้อยู่ในโหมด Output | |
pinMode(LEDARRAY_A, OUTPUT); //กำหนด Pin ให้อยู่ในโหมด Output |
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
void loop() | |
{ | |
Display(Display_Swap_Buffer); //ฟังก์ชั่นในการเลื่อนตัวอักษร | |
Calc_Shift(Display_Num_Word); //ฟังก์ชั่นในการคำณวนการเลือนของตัวอักษร | |
Shift_Count++; //เพิ่มจำนวนการนับที่ใช้ในการเลื่อนบิตที่ละ 1 | |
if(Shift_Count%16 == 0) //ตรวจสอบเลื่อนบิตเมื่อครบ 16 ครั้ง | |
{ | |
Message_index++; //เพิ่มตำแหน่งข้อความที่ละ 1 | |
} | |
if(Message_index > (serial_index - 1)) //ตรวจสอบจำนวนข้อความเทียบกับข้อความที่รับเข้ามา |
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
void Clear_Display() | |
{ | |
unsigned char n,j; | |
for(j = 0 ; j < Display_Num_Word; j++) | |
{ | |
for(n = 0 ; n < 32 ;n++) | |
{ | |
Display_Swap_Buffer[j][n] = 0xFF; | |
} | |
} |
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
void Calc_Shift(unsigned int Display) | |
{ | |
unsigned char n,j; | |
for(n = 0;n < 16;n++) | |
{ | |
if((Display_Swap_Buffer[0][16+n]&0x80) == 0) | |
{ | |
Display_Swap_Buffer[0][n] = (Display_Swap_Buffer[0][n] << 1)&0xfe; | |
} | |
else |
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
void Display(const unsigned char dat[][32]) | |
{ | |
unsigned char n; | |
for( n = 0 ; n < 16 ; n++ ) | |
{ | |
for(int j = 0 ; j < Display_Num_Word ; j++) | |
{ | |
digitalWrite(LEDARRAY_G, HIGH); | |
int sum = j*2; | |
Display_Buffer[sum] = dat[j][n]; |
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
void Scan_Line( unsigned char m) | |
{ | |
switch(m) | |
{ | |
case 0: | |
digitalWrite(LEDARRAY_D, LOW);digitalWrite(LEDARRAY_C, LOW);digitalWrite(LEDARRAY_B, LOW);digitalWrite(LEDARRAY_A, LOW); | |
break; | |
case 1: | |
digitalWrite(LEDARRAY_D, LOW);digitalWrite(LEDARRAY_C, LOW);digitalWrite(LEDARRAY_B, LOW);digitalWrite(LEDARRAY_A, HIGH); | |
break; |
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
void shiftOutSPI( unsigned char dat ) | |
{ | |
digitalWrite( STCP_PIN, LOW); | |
digitalWrite( STCP_PIN, LOW ); | |
SPI.transfer(dat); | |
digitalWrite( STCP_PIN, HIGH ); | |
digitalWrite( STCP_PIN, LOW ); | |
} |
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
void serialEvent() | |
{ | |
byte buff; | |
if(Serial.available()) | |
{ | |
buff = Serial.read(); | |
if(buff == 59) | |
{ | |
serial_index = 0; | |
} |
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 <SoftwareSerial.h> | |
char c=0; | |
char str[40]; | |
char cnt=0; | |
int busy = 2; | |
int LED1 = 3; | |
int LED2 = 4; | |
int LED3 = 5; | |
int LED4 = 6; | |
String password="1234"; |