#define BAUD 115200 //Pin connected to ST_CP of 74HC595 int latchPin = 13; //Pin connected to SH_CP of 74HC595 int clockPin = 12; ////Pin connected to DS of 74HC595 int dataPin = 11; byte min1=0; byte min0=0; byte hora1=0; byte hora0=0; byte dia1=0; byte dia0=0; byte mes1=0; byte mes0=0; byte year_a0=0; byte year_a1=0; byte year_b1=0; byte year_b0=0; byte minuto=0; byte hora=0; byte dia=1; byte mes=1; byte year_a=0; byte year_b=0; int year=2012; byte time=60; byte res=1; byte ready = true; byte display0[10]= {119,65,59,107,77,110,126,67,127,111}; ISR(TIMER2_OVF_vect) { sei(); //Reenable global interrupts, otherwise serial commands will get dropped if( Serial.available() > 7 ) { if (Serial.read()==0xF0){ year_a=Serial.read(); year_b=Serial.read(); year=year_a*100+year_b; mes=Serial.read(); dia=Serial.read(); hora=Serial.read(); minuto=Serial.read(); min1=minuto/10; min0=minuto%10; time=Serial.read(); res=Serial.read(); digitalWrite(latchPin, 0); shiftOut(dataPin, clockPin, display0[dia1]); shiftOut(dataPin, clockPin, display0[dia0]); shiftOut(dataPin, clockPin, display0[mes1]); shiftOut(dataPin, clockPin, display0[mes0]); shiftOut(dataPin, clockPin, display0[year_a1]); shiftOut(dataPin, clockPin, display0[year_a0]); shiftOut(dataPin, clockPin, display0[year_b1]); shiftOut(dataPin, clockPin, display0[year_b0]); shiftOut(dataPin, clockPin, display0[hora1]); shiftOut(dataPin, clockPin, display0[hora0]); shiftOut(dataPin, clockPin, display0[min1]); shiftOut(dataPin, clockPin, display0[min0]); digitalWrite(latchPin, 1); //Serial.print("Minutos: "); //minuto=(min1*10)+(min0); //Serial.print(minuto); //Serial.print(" Tiempo ficcion: "); //Serial.print(time); } } } void setup() { //Start Serial for debuging purposes Serial.begin(BAUD); //set pins to output because they are addressed in the main loop pinMode(latchPin, OUTPUT); TCCR2A = 0; TCCR2B = 0<12) { mes=1; year=year+1; year_a=year/100; year_b=year%100; } } void shiftOut(int myDataPin, int myClockPin, byte myDataOut) { // This shifts 8 bits out MSB first, //on the rising edge of the clock, //clock idles low //internal function setup int i=0; int pinState; pinMode(myClockPin, OUTPUT); pinMode(myDataPin, OUTPUT); //clear everything out just in case to //prepare shift register for bit shifting digitalWrite(myDataPin, 0); digitalWrite(myClockPin, 0); //for each bit in the byte myDataOut… //NOTICE THAT WE ARE COUNTING DOWN in our for loop //This means that %00000001 or "1" will go through such //that it will be pin Q0 that lights. for (i=7; i>=0; i--) { digitalWrite(myClockPin, 0); //if the value passed to myDataOut and a bitmask result // true then... so if we are at i=6 and our value is // %11010100 it would the code compares it to %01000000 // and proceeds to set pinState to 1. if ( myDataOut & (1<