อุปกรณ์
1.
Dot matrix สีแดง ใช้ไฟเลี้ยง 5 V เป็นขา common cathode
2.
Board Driver สีแดง เป็นตัว Driver dotmartrix ใช้ชิพ 74HC595
เป็น
ชิพที่ใช้เพิ่มขา Analog ใช้ทั้งหมด 2
ตัว
Common cathode คือ รูป
ขวา common Anode รูป ซ้าย ถ้าเกิดจ่ายไฟสลับทางกัน จะไม่เกิดการซ็อต ที่ dot
matrix เพราะ Diode จะเป็นตัวต้านการไหลของกระแสไฟฟ้า(ถ้าไฟเลี้ยงสูงก็ทำให้ซ็อตได้) แต่จะทำให้ Dotmatrix มีการแสดงผลร่วนไป
EX Code ใช้กับชิพ 74hc595
dot matrix common cathode
const int latchPin = 15;//15 4 Pin connected to ST_CP of 74HC595
const int clockPin = 14;//14 13 Pin connected to SH_CP of 74HC595
const int dataPin = 13; //13 11 Pin connected to DS of 74HC595
int data[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*" ",0*/
0x00, 0x00, 0x00, 0x7C, 0x82, 0x82, 0x7C, 0x00, /*"0",1*/
0x00, 0x00, 0x00, 0x84, 0xFE, 0x80, 0x00, 0x00, /*"1",2*/
0x00, 0x00, 0x00, 0xC4, 0xA2, 0x92, 0x8C, 0x00, /*"2",3*/
0x00, 0x00, 0x00, 0x44, 0x92, 0x92, 0x6C, 0x00, /*"3",4*/
0x00, 0x00, 0x00, 0x70, 0x4C, 0xFE, 0x40, 0x00, /*"4",5*/
0x00, 0x00, 0x00, 0x9E, 0x92, 0x92, 0x62, 0x00, /*"5",6*/
0x00, 0x00, 0x00, 0x7C, 0x92, 0x92, 0x64, 0x00, /*"6",7*/
0x00, 0x00, 0x00, 0x06, 0xE2, 0x12, 0x0E, 0x00, /*"7",8*/
0x00, 0x00, 0x00, 0x6C, 0x92, 0x92, 0x6C, 0x00, /*"8",9*/
0x00, 0x00, 0x00, 0x4C, 0x92, 0x92, 0x7C, 0x00, /*"9",10*/
0x00, 0x00, 0x00, 0xFC, 0x22, 0x22, 0xFC, 0x00, /*"A",11*/
0x00, 0x00, 0x00, 0xFE, 0x92, 0x92, 0x6C, 0x00, /*"B",12*/
0x00, 0x00, 0x00, 0x7C, 0x82, 0x82, 0x44, 0x00, /*"C",13*/
0x00, 0x00, 0x00, 0xFE, 0x82, 0x82, 0x7C, 0x00, /*"D",14*/
0x00, 0x00, 0x00, 0xFE, 0x92, 0x92, 0x82, 0x00, /*"E",15*/
0x00, 0x00, 0xFE, 0x12, 0x12, 0x02, 0x00, 0x00, /*"F",16*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*" ",17*/
};
void setup ()
{
//set pins to output
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
Serial.begin(115200);
ESP.wdtDisable(); //ปิด watch dog Timer
}
void loop()
{
// Serial.println("aoouoiuoiuoiuo");
// for (int n = 0; n < 8; n++) // ทำให้ไฟเลื่อน
// {
for (int t = 0; t < 500; t ++) //Show repeated 10 times (node mcu 100-1000)
{
int n = 24;
int dat = 0x01;
for (int num = n; num < 8 + n; num++) // for (int num = n; num < 8 + n; num++)
{ ESP.wdtFeed();
shiftOut(dataPin, clockPin, MSBFIRST, ~data[num]); //control ROW of dot matrix
shiftOut(dataPin, clockPin, LSBFIRST, (dat)); //control COL of dot matrix
//return the latch pin high to signal chip that it
//no longer needs to listen for information
digitalWrite(latchPin, HIGH); //pull the latchPin to save the data
// delay(10); //wait for a microsecond
digitalWrite(latchPin, LOW); //ground latchPin and hold low for as long as you are transmitting
// delay(100); //wait for a microsecond
dat = dat << 1;
}
}
// }
Serial.println("done");
}
EX Code ใช้กับชิพ 74hc595
dot matrix common anode
const int latchPin = 4;//Pin connected to ST_CP of 74HC595
const int clockPin = 13;//Pin connected to SH_CP of 74HC595
const int dataPin = 11; //Pin connected to DS of 74HC595
int data[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,/*" ",0*/
0xFF,0xC1,0xBE,0xBE,0xBE,0xC1,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xDF,0xDF,0x80,0xFF,/*"1",2*/
0xFF,0xDC,0xBC,0xBA,0xB6,0xCE,0xFF,0xFF,/*"2",3*/
0xFF,0xDD,0xBE,0xB6,0xB6,0xC9,0xFF,0xFF,/*"3",4*/
0xFB,0xF3,0xEB,0xDB,0x80,0xFB,0xFF,0xFF,/*"4",5*/
0xFF,0x8D,0xAE,0xAE,0xAE,0xB1,0xFF,0xFF,/*"5",6*/
0xFF,0xC1,0x96,0xB6,0xB6,0xD9,0xFF,0xFF,/*"6",7*/
0xFF,0xBF,0xBC,0xB3,0xAF,0x9F,0xFF,0xFF,/*"7",8*/
0xFF,0xC9,0xB6,0xB6,0xB6,0xC9,0xFF,0xFF,/*"8",9*/
0xFF,0xCD,0xB6,0xB6,0xB4,0xC1,0xFF,0xFF,/*"9",10*/
0xFC,0xF3,0xCB,0x9B,0xEB,0xF3,0xFC,0xFF,/*"A",11*/
0xFF,0x80,0xB6,0xB6,0xB6,0xB6,0xC9,0xFF,/*"B",12*/
0xFF,0xE3,0xDD,0xBE,0xBE,0xBE,0xBE,0xDD,/*"C",13*/
0xFF,0x80,0xBE,0xBE,0xBE,0xBE,0xDD,0xE3,/*"D",14*/
0xFF,0x80,0xB6,0xB6,0xB6,0xB6,0xBE,0xFF,/*"E",15*/
0xFF,0x80,0xB7,0xB7,0xB7,0xB7,0xBF,0xFF,/*"F",16*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,/*" ",0*/};/*"0",1*/
void setup ()
{
//set pins to output
pinMode(latchPin,OUTPUT);
pinMode(clockPin,OUTPUT);
pinMode(dataPin,OUTPUT);
}
void loop()
{
for(int n = 0; n < 136; n++)
{
for(int t=0;t<100 8="" clockpin="" dat="" data="" datapin="" delay="" digitalwrite="" for="" int="" latchpin="" n="" num="" pre="" shiftout="" t="">
Dot matrix จะเป็นตัวแสดงผลหลังจากที่ เด็กมีการวาดรูปลงใน taplet แล้ว taplet จะส่งข้อมูลที่เด็กวาดในรูปของ
BINARY 64 bit ต่อ 1 dotmatrix ใช้ทั้งหมด 9
ตัว
แต่ละตัวจะได้รับข้อมูลจาก taplet ที่ไม่เหมือนกัน ซึ่ง รวมแล้ว taplet จะต้องส่งข้อมูล
64 bit ทั้งหมด 9 ครั้ง
Dot matrix ไม่จำเป็นต้องใช้ ชนิดนี้ก็ได้ อาจจะไปใช้ตัวที่เล่น RGB ได้แต่ในครั้งนี้เราถูกจำกัดด้วยงบ
ไม่มากพอ
วิธีเลือก Dot matrix เราต้องเลือกให้ เหมาะสมกับ board driver แต่ละชนิด
1.
ชิพ 74HC595 เล่น 1
สี
1.
ชิพ MAX 7219 เล่น 1
สี
1.
Module driver Color shield RGB
100>








ไม่มีความคิดเห็น:
แสดงความคิดเห็น