Remote controlled countdown timer

Hi,

I'm a complete newbie and am trying out a few projects using the Arduino Uno and a starter kit. I am trying to build a remote controlled countdown timer but can't get it to work. I've already configured the remote control but when I push any buttons nothing happens except the IC Receiver blinks. The LED screen's backlight comes on when I connect the USB to my Mac but it does nothing else. Attached is my Fritzing schematic and the code is below.

#include <LiquidCrystal.h>
#include<IRremote.h>
int RECV_PIN = 0;
IRrecv irrecv(RECV_PIN);
decode_results results;
LiquidCrystal lcd(10, 9, 5, 4, 3, 2);
void setup() {
  lcd.begin(16, 2);
  lcd.write("Enter Time:");
  lcd.setCursor(9, 2);
  lcd.write("seconds");
  lcd.setCursor(0, 1); lcd.blink();
  irrecv.enableIRIn();
  Serial.begin(9600);
}

String x = "";
int y = 0;
void loop()
{
  if (irrecv.decode(&results))
  {
    switch (results.value)
    {
      case 0xFFA25D:      analogWrite(A5, 0); lcd.clear(); lcd.print("Enter Time:"); lcd.setCursor(9, 2); lcd.write("seconds"); x = ""; lcd.setCursor(0, 1); lcd.blink(); break; //PWR
      case 0xFF02FD:
        y = x.toInt();
        for (int i = y; i >= 0; i--) {
          if (i == 0) {
            analogWrite(A5, 255);
            lcd.clear();
            lcd.noCursor();
            lcd.print("TIME's UP");
            break;
          }
          lcd.noCursor();
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print("Remaining Time:");
          lcd.setCursor(0, 1);
          lcd.print(i, DEC);
          lcd.setCursor(9, 2);
          lcd.print("seconds");
          delay(999);
        }     break;            //PLAY/PAUSE

      case 0xFF6897:           x = x + "0"; lcd.setCursor(0, 1); lcd.print(x); break;       //0
      case 0xFF30CF:           x = x + "1"; lcd.setCursor(0, 1); lcd.print(x); break;       //1
      case 0xFF18E7:           x = x + "2"; lcd.setCursor(0, 1); lcd.print(x); break;       //2
      case 0xFF7A85:           x = x + "3"; lcd.setCursor(0, 1); lcd.print(x); break;       //3
      case 0xFF10EF:           x = x + "4"; lcd.setCursor(0, 1); lcd.print(x); break;       //4
      case 0xFF38C7:           x = x + "5"; lcd.setCursor(0, 1); lcd.print(x); break;       //5
      case 0xFF5AA5:           x = x + "6"; lcd.setCursor(0, 1); lcd.print(x); break;       //6
      case 0xFF42BD:           x = x + "7"; lcd.setCursor(0, 1); lcd.print(x); break;       //7
      case 0xFF4AB5:           x = x + "8"; lcd.setCursor(0, 1); lcd.print(x); break;       //8
      case 0xFF52AD:           x = x + "9"; lcd.setCursor(0, 1); lcd.print(x); break;       //9
    }
    irrecv.resume();
  }
}

Is my code and/or my wiring wrong? Any suggestions would be greatly appreciated!

int RECV_PIN = 0;

Don't use pin 0, or pin 1 for that matter. They are used by the Serial interface

Thanks, I tried changing the code to 6 and putting the wire into the digital pin 6 but same result.

The LED screen's backlight comes on when I connect the USB to my Mac but it does nothing else

Forget your program for now.
Does the LCD "Hello World" program work ?

Hi reddoorescape
I am definately a noob on these too, buit I do see something

 delay(999);

that wont help anything

have a read on robin2's most excellent threads on designing your project sketch the right way and having it do lots at the same time :slight_smile:

http://forum.arduino.cc/index.php?topic=261445.0
http://forum.arduino.cc/index.php?topic=223286.0

i wish i'd seen these a couple of years ago ...

Thanks UKHeliBob, Hello World works fine on the LCD.

  lcd.begin(16, 2);

Your LCD has 16 columns numbered 0 to 15 and 2 rows numbered 0 to 1

  lcd.setCursor(9, 2);
  lcd.write("seconds");

Why are you writing to row 2, which does not exist ?

Nevermind, I resolved my own problem. I had the 10k pots wired incorrectly - mixed up the positive and negative. Just need to get the buzzer working. Thanks for all your help!

Are you still writing to a row on the LCD that does not exist ?

I didn't change any of the code except for int RECV_PIN = 0 as you suggested, so yes I am still writing to the second row. I used pin 8.

Everything works from the reset to play buttons to inserting the number of seconds for the countdown. The LED lights up when the timer is 0 but the buzzer doesn't work. I have an active buzzer with the longer pin wired into the output of the 10k pot and the shorter pin wired to the negative rail. Any suggestions for that? Thanks!

yes I am still writing to the second row.

If you are still doing

  lcd.setCursor(9, 2);
  lcd.write("seconds");

Then you are trying to write to the third row

Are you implying that that piece of code is affecting the buzzer to sound? I've wired the buzzer straight into 5V and it works so there is something wrong with the code and/or wiring.

Are you implying that that piece of code is affecting the buzzer to sound?

No, but it's wrong anyway