//////////////////////////////// // 4 Digit 7 Segment Display // // // // This program allows the // // user to set-up a 4 digit 7 // // segment display. // // // // Codes by: // // eGizmo Mechatronix Central // // Taft, Manila Philippines // // http://www.egizmo.com // // April 18, 2013 // //////////////////////////////// // Constants const int DataIN = 5; // Connect data IN to MCU pin 5 const int StrIN = 6; // Connect str IN to MCU pin 6 const int ClkIN = 7; // Connect clk IN to MCU pin 7 // This pins are located on the left side of the // display // Data in 5th pin // Str in 4th pin // Clk in 3rd pin // Timer numbers const byte numbersTimer[10]={ B10111111, //0 B10000110, //1 B11011011, //2 B11001111, //3 B11100110, //4 B11101101, //5 B11111101, //6 B10100111, //7 B11111111, //8 B11101111}; //9 // NOTE: Use an external supply more than 5V so that // the display will be more clear. void setup() { pinMode(DataIN, OUTPUT); // Pin 5 as output pinMode(ClkIN, OUTPUT); // Pin 6 as output pinMode(StrIN, OUTPUT); // Pin 7 as output } void loop() { // This following codes are for testing: for(int i = 0; i<=6; i++) { shiftOut(numbersTimer[0+i]); // 4th digit digitalWrite(StrIN, HIGH); digitalWrite(StrIN,LOW); shiftOut(numbersTimer[1+i]); // 3rd digit digitalWrite(StrIN, HIGH); digitalWrite(StrIN,LOW); shiftOut(numbersTimer[2+i]); // 2nd digit digitalWrite(StrIN, HIGH); digitalWrite(StrIN,LOW); shiftOut(numbersTimer[3+i]); // 1st digit digitalWrite(StrIN, HIGH); digitalWrite(StrIN,LOW); delay(1000); // Delay per display } } void shiftOut(byte DataOUT) // Sets a byte called DataOUT { boolean state; // Sets the cycle for data in and clock in digitalWrite(DataIN, LOW); digitalWrite(ClkIN, LOW); for (int i=0; i<=7; i++) // This is set for 8bit binary. { digitalWrite(ClkIN, LOW); if (DataOUT&(1<