At a loss, please help

Ok guys Im officially stumped with this one. Ive been trying different things for a few hours, and nothing is doing what I want. I need a system with 2 buttons, temp up and temp down, which will count from 1 to 18, once 1 or 18 is reached, it will stop counting, unless it starts moving in the other direction. I can then use the count = # to activate what I want. Ive gotten it to count up and stop at 18, but going the other direction is the issue. I will upload what I have that works. Any advice here:

Im a NOOB so go easy!! haha.

//thanks to darudude for the code for this section

int inPinUP = 23; //temp up button
int inPinDN = 25; //temp down button
int readingUP;           // the current reading from the input pin
int readingDN;
int previousUP = LOW;    // the previous reading from the input pin
int previousDN = LOW;
int count=0; //current position count

long time = 0;         // the last time the output pin was toggled
long debounce = 200;   // the debounce time, increase if the output flickers

void setup()
{
  pinMode(inPinUP, INPUT);
  pinMode(inPinDN, INPUT);
  Serial.begin (9600);
}

void loop()
{
  readingUP = digitalRead(inPinUP);

  // if we just pressed the button (i.e. the input went from LOW to HIGH),
  // and we've waited long enough since the last press to ignore any noise...  
  if (readingUP == HIGH && previousUP == LOW && millis() - time > debounce) {
    //increment count
    count++;

    // ... and remember when the last button press was
    time = millis();    
  }
  previousUP = readingUP;

  if (count==19)
  {
    //whatever you want to do over here
    count=18; //reset count


  }
  Serial.print (count, DEC);
}

just thought of another way to explain what I am trying to accomplish, basically a 2-way decade counter, that will count from 1 to 18. if that helps at all.

if (readingUP == HIGH && previousUP == LOW && millis() - time > debounce) {

Why are you trying to do everything at once? How about:

buttonUpTransition = read_and_debounce(inpinup);
buttonDownTransition = read_and_debounce(inpindn);

if (buttonUpTransition == BUTTONPRESSED && count < 18) {
  count++;
} else if (buttonDownTransition == BUTTONPRESSED && count > 0) {
  count--;
}

Other possible return values for read_and_debounce() might include BUTTONHELD, BUTTONRELEASED, and BUTTONIDLE.

makes more sense like that. There are still a lot of commands I need to learn, but Im workin on it. Ill mess with that tomorrow and post up my results. Thanks for the input.

Hey Westfw, I am trying to get the code you posted up and running, but Im not sure how to call some of the functions. I have the int for count taken care of, but the buttontransion and buttonpressed commands, as well as the read_and_debounce, honestly Im not sure how to implement them. Any advice. This is the one hard thing about Arduino for me, I can read all the books in the world and not get it, but as soon as I see it done it makes sense to me. Im not trying to have someone else do my work for me, I just need some guidance. Ive read 3 different Arduino books, and the code you guys all post on here has done more for me then all that reading. No wonder college was so hard! haha.

Unless you’re particularly interested in learning how to debounce buttons and such, you could use one of the existing libraries that does the work for you. (actually, “Button” doesn’t seem to do any debouncing, so I have a delay in here that should do that, sort of.)
I haven’t actually used any of the Button Libraries, so I can’t really talk about details, but the following bit of code seems to compile ok…

#include <Button.h>

Button upbutton = Button(23, PULLDOWN);
Button downbutton = Button(25, PULLDOWN);
byte count;

void setup() {
}

void loop()
{
  if (upbutton.uniquePress() && count < 18) {
    count++;
    Serial.print(count, DEC);
  }
  if (downbutton.uniquePress() && count > 0) {
    count--;
    Serial.print(count, DEC);
  }
  delay(100); // Button doesn't actually debounce, so this will have to do.
}

ya i did a similar thing with putting a delay after the button read. worked pretty well so far. I think the pull-down resistor helps with the signal too. Thanks for your input!!