#include "wiring.h" // // 14-Segment Red LED Display LTM-8647AP by LITE-ON // // AAAAAAA AAAAAAA // FK M NB FK M NB // F K M N B F K M N B // F KMN B F KMN B // GGG HHH GGG HHH // E TSR C E TSR C // E T S R C E T S R C // ET S RC ET S RC // DDDDDDD dp DDDDDDD dp // // Digit 1 Digit 2 // // Data sequence: // digit: 222222222222221111111111111112 // segment: 1ABCDEFGHKMNRSTABCDEFGHKMNRSTddxx00 // curDisplay ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The leading 1 and trailing 00 are not included. // // Character Font Table. // static int fontTbl[224] = { /* */0x0000, /*!*/0x3001, /*"*/0x2020, /*#*/0x07A4, /*$*/0x5BA4, /*%*/0x13DA, /*&*/0x4D68, /*'*/0x0010, /*(*/0x0018, /*)*/0x0042, /***/0x01FE, /*+*/0x01A4, /*,*/0x0002, /*-*/0x0180, /*.*/0x0001, /*/*/0x0012, /*0*/0x7E12, /*1*/0x3010, /*2*/0x6D80, /*3*/0x7880, /*4*/0x3380, /*5*/0x4B08, /*6*/0x5F80, /*7*/0x7200, /*8*/0x7F80, /*9*/0x7380, /*:*/0x0024, /*;*/0x0022, /*<*/0x0118, /*=*/0x0980, /*>*/0x00C2, /*?*/0x6085, /*@*/0x6E90, /*A*/0x7780, /*B*/0x78A4, /*C*/0x4E00, /*D*/0x7824, /*E*/0x4F00, /*F*/0x4700, /*G*/0x5E80, /*H*/0x3780, /*I*/0x4824, /*J*/0x3C00, /*K*/0x0718, /*L*/0x0E00, /*M*/0x3650, /*N*/0x3648, /*O*/0x7E00, /*P*/0x6780, /*Q*/0x7E08, /*R*/0x6788, /*S*/0x5B80, /*T*/0x4024, /*U*/0x3E00, /*V*/0x0612, /*W*/0x360A, /*X*/0x005A, /*Y*/0x2384, /*Z*/0x4812, /*[*/0x3098, /*\*/0x0048, /*]*/0x0742, /*^*/0x0240, /*_*/0x0800, /*`*/0x0040, /*a*/0x0D44, /*b*/0x0F04, /*c*/0x0D00, /*d*/0x0D24, /*e*/0x0D02, /*f*/0x40A4, /*g*/0x4B24, /*h*/0x0704, /*i*/0x0004, /*j*/0x0422, /*k*/0x003C, /*l*/0x0024, /*m*/0x1584, /*n*/0x0504, /*o*/0x1D80, /*p*/0x4720, /*q*/0x4324, /*r*/0x0500, /*s*/0x4B04, /*t*/0x01A4, /*u*/0x0C04, /*v*/0x0402, /*w*/0x140A, /*x*/0x005A, /*y*/0x0054, /*z*/0x0902, /*{*/0x4942, /*|*/0x0600, /*}*/0x4898, /*~*/0x0050, /*¦*/0x7FFE }; const int LED_CLOCK_PIN = 3; // 14-Seg Clock bus const int LED_DATA_PIN = 4; // 14-Seg Data bus const int buttonPin = 5; // Hard to get to push button on buzzer const int IRPin = 6; // Infered detector const int buzzerPin = 7; // Buzzer pin (HIGH = on) const int LED_ENABLE_PIN = 8; // Enable a 14-seg chip after address lines are set const int LED_ADDR0_PIN = 14; // Address line 0 const int LED_ADDR1_PIN = 15; // Address line 1 const int LED_ADDR2_PIN = 16; // Address line 2 const int LED_ADDR3_PIN = 17; // Address line 3 void delay300ns() { int i=0; while( i < 100 ) i++; } //#define HIGH 0x1 //#define LOW 0x0 //void digitalWrite( int, int ); void sendToChip( int chip, long data ) { // Init Clock, Data, Enable pins digitalWrite( LED_CLOCK_PIN, LOW ); digitalWrite( LED_DATA_PIN, LOW ); digitalWrite( LED_ENABLE_PIN, HIGH ); // Inactive // Load address line with i. digitalWrite( LED_ADDR0_PIN, (chip & 0x01) ); digitalWrite( LED_ADDR1_PIN, (chip & 0x02) ); digitalWrite( LED_ADDR2_PIN, (chip & 0x04) ); digitalWrite( LED_ADDR3_PIN, (chip & 0x08) ); // Enable the chip digitalWrite( LED_ENABLE_PIN, LOW ); // Low active delay300ns(); // Toggle the clock 36 time sending: 1dddddddddddddddddddddddddddddddd000. digitalWrite( LED_DATA_PIN, 1 ); // Output a "1" delay300ns(); digitalWrite( LED_CLOCK_PIN, HIGH );// Read the data on the rising edge. delay300ns(); for( int i=0; i<32; i++ ) { digitalWrite( LED_CLOCK_PIN, LOW );// Reset the clock. // Set the data pin to the high order bit of data. delay300ns(); digitalWrite( LED_DATA_PIN, (data<0) ? 1 : 0 ); // Shift in the next bit. data <<= 1; delay300ns(); digitalWrite( LED_CLOCK_PIN, HIGH );// Read the data on the rising edge. delay300ns(); } // Write the last 3 bits. Doesn't matter what they are. for( int i=0; i<3; i++ ) { digitalWrite( LED_CLOCK_PIN, LOW ); // Reset the clock. delay300ns(); digitalWrite( LED_DATA_PIN, 0 ); // Output a "0" delay300ns(); digitalWrite( LED_CLOCK_PIN, HIGH );// Read the data on the rising edge. delay300ns(); } digitalWrite( LED_ENABLE_PIN, HIGH ); // Inactive }