- 
/* 
- 
  
- 
 The LCD: 
- 
 * LCD RS pin to digital pin 12 
- 
 * LCD Enable pin to digital pin 11 
- 
 * LCD D4 pin to digital pin 5 
- 
 * LCD D5 pin to digital pin 4 
- 
 * LCD D6 pin to digital pin 3 
- 
 * LCD D7 pin to digital pin 2 
- 
 * LCD R/W pin to ground 
- 
 * ground to LCD VO pin (pin 3) 
- 
  
- 
 Remote Reciever: 
- 
 *Middle pin to pin 6 
- 
 *Sides to 5V and ground 
- 
  
- 
*/ 
- 
  
- 
  
- 
#include <LiquidCrystal.h> 
- 
#include <IRremote.h> 
- 
  
- 
  
- 
#define bPOW  0xFFA25D 
- 
#define bMODE 0xFF629D 
- 
#define bMUTE 0xFFE21D 
- 
#define bPREV 0xFF22DD 
- 
#define bNEXT 0xFF02FD 
- 
#define bPLAY 0xFFC23D 
- 
#define bMINUS 0xFFE01F 
- 
#define bPLUS 0xFFA857 
- 
#define bEQ 0xFF906F 
- 
#define b0 0xFF6897 
- 
#define b100+ 0xFF9867 
- 
#define bRET 0xFFB04F 
- 
#define b1 0xFF30CF 
- 
#define b2 0xFF18E7 
- 
#define b3 0xFFFFFF 
- 
#define b4 0xFF10EF 
- 
#define b5 0xFF38C7 
- 
#define b6 0xFF5AA5 
- 
#define b7 0xFF42BD 
- 
#define b8 0xFF4AB5 
- 
#define b9 0xFF52AD 
- 
  
- 
  
- 
int RECV_PIN = 6; 
- 
IRrecv irrecv(RECV_PIN); 
- 
decode_results results; 
- 
  
- 
int set = 0; 
- 
int pass = 1; 
- 
  
- 
// initialize the library with the numbers of the interface pins 
- 
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 
- 
volatile byte seconds =50; 
- 
volatile byte minutes =59; 
- 
volatile byte hours   =9; 
- 
  
- 
void setup() { 
- 
  // set up the LCD's number of columns and rows: 
- 
  lcd.begin(16, 2); 
- 
  irrecv.enableIRIn(); // Start the receiver 
- 
  // Print a message to the LCD. 
- 
  TCCR1A = 0; 
- 
  TCCR1B = 0; 
- 
  OCR1A = 15625; 
- 
  TCCR1B |= (1 << WGM12); 
- 
  TCCR1B |= (1 << CS10); 
- 
  TCCR1B |= (1 << CS12); 
- 
  TIMSK1 |= (1<< OCIE1A); 
- 
  sei(); 
- 
} 
- 
  
- 
void loop() { 
- 
     //Clock Code 
- 
     lcd.setCursor(0, 0); 
- 
     if(hours<10){ 
- 
     lcd.print(" "); 
- 
     } 
- 
     lcd.print(hours,DEC); 
- 
     lcd.setCursor(2, 0); 
- 
     lcd.print(":"); 
- 
     lcd.setCursor(3, 0); 
- 
     if(minutes<10){ 
- 
     lcd.print("0"); 
- 
     } 
- 
     lcd.print(minutes,DEC); 
- 
     lcd.setCursor(5, 0); 
- 
     lcd.print(":"); 
- 
     lcd.setCursor(6, 0); 
- 
     if(seconds<10){ 
- 
     lcd.print("0"); 
- 
     } 
- 
     lcd.print(seconds,DEC); 
- 
     lcd.setCursor(8, 0); 
- 
      
- 
     //Remote Code 
- 
     if (irrecv.decode(&results)) 
- 
     {                                    //Gets input 
- 
       if (results.value == bMODE) 
- 
       {                                  //if its the mode button 
- 
           if(set == 0) 
- 
           { 
- 
             set = 1;                    //we are in set mode 
- 
             irrecv.resume();            // Receive the next value 
- 
           } 
- 
           else if(set == 1) 
- 
           {                            //if we are already set, un-set 
- 
             set = 0;                    //not set anymore 
- 
             irrecv.resume();            //recieve next value 
- 
            } 
- 
         } 
- 
          
- 
         while(set == 1) 
- 
         {                               //while we are setting 
- 
            if(pass == 1)               //If we are in hour column 
- 
            { 
- 
              
- 
              
- 
              
- 
              
- 
            
- 
            
- 
            
- 
            } 
- 
            if(pass == 2)              //if we are in minutes column 
- 
            { 
- 
            
- 
            
- 
            
- 
            
- 
            
- 
            
- 
            
- 
            } 
- 
         } 
- 
     } 
- 
ISR (TIMER1_COMPA_vect){ 
- 
  if(seconds==59){ 
- 
    seconds=0; 
- 
    minutes++; 
- 
    if (minutes==60){ 
- 
      minutes=0; 
- 
      hours++; 
- 
    } 
- 
    if (hours == 24) 
- 
       hours = 0; 
- 
  } 
- 
  else 
- 
  seconds++; 
- 
  
- 
}