RGB fader with up/down buttons

Hi all,
Im writing some code (attached below) that is supposed to control an RGB led.
Whats supposed to happen is that you put the "device" into programming mode with a switch (pgrmPin) and then using 2 up/down buttons per led color select the color. so far nothing is happening.

The final version is meant to run on an attiny2313 that has a ported Arduino bootloader, thats why the pins are set the way they are. I have tried however to change the pin and run it on my Duemlinanove but still no success.
(yes the leds and buttons work)
if anyone can help it would be really appreciated.

Nadav.

const int redPin   =   13; //Define red led
const int greenPin =   12;//Define green led
const int bluePin  =   11;//Define blue led
const int pgrmPin  =   10;//Define program switch
const int pgrmRUPin =   7;//Define red up button
const int pgrmGUPin =   6;//Define green up button
const int pgrmBUPin =   5;//Define blue up button
const int pgrmRDPin =   4;//Define red down button
const int pgrmGDPin =   3;//Define green down button
const int pgrmBDPin =   2;//Define blue down button
int red = 0;
int blue = 0;
int green = 0;

void setup() {
  pinMode(redPin, OUTPUT);     //PWM PIN 13 (PB4)
  pinMode(greenPin, OUTPUT);     //PWM PIN 12 (PB3)
  pinMode(bluePin, OUTPUT);     //PWM PIN 11 (PB2)
  pinMode(pgrmPin, INPUT);     //Digital PIN 10 (PB1)
  pinMode(pgrmRUPin, INPUT);     //Digital PIN 7 (PD5)
  pinMode(pgrmGUPin, INPUT);     //Digital PIN 6 (PD4)
  pinMode(pgrmBUPin, INPUT);     //Digital PIN 5 (PD3)
  pinMode(pgrmRDPin, INPUT);     //Digital PIN 4 (PD2)
  pinMode(pgrmGDPin, INPUT);     //Digital PIN 3 (PA0)
  pinMode(pgrmBDPin, INPUT);     //Digital PIN 2 (PA1)
}

void loop() {
  if (pgrmPin == HIGH){//Enter Program mode
    if (pgrmRUPin == HIGH && red >= 0 && red < 255){
      red++;
    }
    if (pgrmRDPin == HIGH && red > 0 && red <= 255){
      red--;
    }

    if (pgrmGUPin == HIGH && green >= 0 && green < 255){
      green++;
    }
    if (pgrmGDPin == HIGH && green > 0 && green <= 255){
      green--;
    }
    if (pgrmBUPin == HIGH && blue >= 0 && blue < 255){
      blue++;
    }
    if (pgrmBDPin == HIGH && blue > 0 && blue <= 255){
      blue--;
    }
    analogWrite(redPin, red);
    analogWrite(greenPin, green);
    analogWrite(bluePin, blue);
}
 analogWrite(redPin, red);
 analogWrite(greenPin, green);
 analogWrite(bluePin, blue);
}
const int pgrmPin  =   10;//Define program switch

void setup() {
  pinMode(pgrmPin, INPUT);     //Digital PIN 10 (PB1)
}

void loop() {
  if (pgrmPin == HIGH)
}

Since prgmPin is set to 10 it will never be equal to HIGH (1). What you meant to say is:

  if (digitalRead(prgmPin) == HIGH)

Which is equivalent to:

  if (digitalRead(prgmPin))
const int redPin   =   13; //Define red led
const int greenPin =   12;//Define green led
const int bluePin  =   11;//Define blue led

Pins 12 and 13 are not PWM pins on the Duemlinanove.

Do you have pull-ups or something on those pins? How is it wired?

  if (pgrmPin == HIGH){//Enter Program mode
    if (pgrmRUPin == HIGH && red >= 0 && red < 255){
      red++;

The loop function executes thousands of times a second. It is likely it is immediately going to either full on or full off. You need to check for a button press which is different from last time, eg.

if (pgrmRUPin == HIGH && oldpgrmRUPin == LOW)
  {
  if (red >= 0 && red < 255)
    red++;
  delay (10);  // debounce
  }

// detect switch changes
oldpgrmRUPin = pgrmRUPin;

(edit) Plus what John said. You need to read the pin, not just use the pin number.

Great ill try this tonight! I cant believe if forgot to read the pin! silly me :smiley:
Also about pins 12 & 13 they are the pwm on the attiny2313..

Right. I thought you were talking about testing it on your Duemlinanove, hence my comment:

I have tried however to change the pin and run it on my Duemlinanove but still no success.