analog input issuses

hi guy and girls. im new to the arduino.
i have theuno rev 3
im having an issue with using the anolg input for my project.
i have 3 push buttons and two switches
they each run threw a 10k pull down resister.
but only two push button read on the arduino.
and neather of the switches.
what could the issue be?

post your code

And a schematic.

ok here it is

in the drawing pin 11 becomes A4
10 becomes A3
5 A1
4 A2
2 A0

other thing you should probly know is that i made a boo boo and stuck 9v threw the 5 inputs this is y im trying to use the analog input.
silly me.
and the transistor i changed to a relay
and also tried to add in a wake up funtion for the camera with a second relay.

so i may well have messed this whole thing up.

sketch_interrev5.ino (9.91 KB)

the code dont fit
so here is the first half

//pins on the arduino.
const int shutterPin = 3;  //output to camera
const int startLEDPin = 13;  //visual display of timelapse running
const int upPin = A1;  //input for up button
const int downPin = A2;  //input for down button
const int minutePin = A3;  //visual display of minutes yes/no (seconds in active if not HIGH)

const int HDRPin = A4; //visual display of HDR yes/no
const int startPin = A0; //input for begin button
const int wakepin = 12;

//for displaying digits on the 7-segment LEDs.
const int clockPin = 6;
const int serialOnesPin = 7;
const int serialTensPin = 8;
const int serialHundsPin = 9;

const int a=1; 
const int b=2; 
const int c=4; 
const int d=8; 
const int e=16; 
const int f=32; 
const int g=64;

byte digits[10];
byte inf[3];
byte pic[3];
byte intvl[3];

//interval settings
long interval = 10; //seconds
long oldInterval; 
long intervalCounter = 0;  //this variable and the next allow for incrementation of the interval
long intervalStep = 10;  //so that the timelapse can be interrupted at any time.

int infoDelay = 1500;
int wakeup = 300;          //time to activate wakeup (focus)
int wakewait =200;         //time between wake and shutter

//number of pictures to be taken total
boolean changeNumPics = true;
int oldNumPics = 0;
int numPics = 0; //total number of pictures, 0 means infinite.
long numPicsChanged = infoDelay;
long numPicsTimeout = 2000; //ms
int count = 0;  //keeps track of number of pictures.

//variables for different options (HDR and minute/second)
boolean minute = false;
int minuteMultiplier = 1;
boolean HDR = false;  //flag for hdr timelapses

//button logic and debouncing
boolean start = false; //records whether timelapse should be going or not.
int startReading;  //reads start button input
int prevStartReading = LOW;  //stores last start button input for latching.
int upReading;  //reads up/down button input
int prevUpReading = LOW;  //stores last up button input for latching.
int downReading;  //reads down button input
int prevDownReading = LOW;  //stores last down button input for latching.

long pressStartTime = 0;  //stores time of last button state change for debouncing
long pressUpTime = 0;  //ditto
long pressDownTime = 0;  //ditto
long debounceDelay = 100;  //debounce wait period in ms

//miscellaneous variables
boolean sleeping = false;
long activityTime = 0;
long sleepTime= 300000; //ms, time to wait before sleeping. (300000 ms = 5 min)
int waitTime;
int safetyDelay = 50; //ms, wait period when camera pin is HIGH to give the camera time to respond
int HDRsafetyDelay = 1500; //ms, time the camera pin is HIGH for fast-fire HDR pictures to be taken

void setup(){
  //declare the pins as inputs or outputs
  pinMode(shutterPin, OUTPUT);
  pinMode(wakepin, OUTPUT);
  
  pinMode(HDRPin, INPUT);
  pinMode(startPin, INPUT);
  pinMode(startLEDPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(serialOnesPin, OUTPUT);
  pinMode(serialTensPin, OUTPUT);
  pinMode(serialHundsPin, OUTPUT);
  pinMode(upPin, INPUT);
  pinMode(downPin, INPUT);
  pinMode(minutePin, INPUT);
  
  //define which segments of the 7-segment LEDs should light for different digits
  digits[0] = a + b + c + d + e + f;
  digits[1] = b + c;
  digits[2] = a + b + g + e + d;
  digits[3] = a + b + g + c + d;
  digits[4] = f + g + b + c;
  digits[5] = a + f + g + c + d;
  digits[6] = a + f + g + c + d + e;
  digits[7] = a + b + c;
  digits[8] = a + b + c + d + e + f + g;
  digits[9] = a + b + f + g + c + d;
  //define the segments for displaying "inf"
  inf[0] = b + c;
  inf[1] = e + g + c;
  inf[2] = a + f + g + e;
  //define the segments for displaying "pic"
  pic[0] = a + b + g + f + e;
  pic[1] = inf[0];
  pic[2] = a + f + e + d;
  //define the segments for displaying "int"
  intvl[0] = b + c;
  intvl[1] = inf[1];
  intvl[2] = f + g + e + d;
  
  Serial.begin(9600);
  //start/stop button is an interrupt so that it's always active
  attachInterrupt(0, checkStart, RISING);
  
  //give some parameter information.
 
 displayPIC();
 delay(infoDelay);
 
 if (numPics == 0){
   displayINF();
 }
 else{
   displayDEC(numPics/10);
 }
  
  while (changeNumPics){
      oldNumPics = numPics;
      checkUp();
      checkDown();
      Serial.println(numPics);
      if (oldNumPics != numPics){
         if (numPics == 0){
           displayINF();
         }
         else{
           displayDEC(numPics/10);
         }
      }
      if (millis() - numPicsChanged > numPicsTimeout){ 
        changeNumPics = false; 
      }
}
  displayINT();
  delay(infoDelay);
  displayDEC(interval);
}

void loop(){ 
  //if timelapse is not running, display the current interval between pictures and be ready
  //to accept input that will change the value of interval.
  if (!start){
    minute = digitalRead(minutePin);
    oldInterval = interval;
    checkUp();
    checkDown();
    if (oldInterval != interval){  //helps reduce flicker in the display
      displayDEC(interval);
    }
  }
  
  while ((count <= numPics || numPics == 0) && start == true){
    sleeping = (millis()-activityTime > sleepTime);
    Serial.println("sleep status");
    Serial.println(sleeping, DEC);

    //set wait time, depending on status of HDR flag.  
    HDR = digitalRead(HDRPin);
    if (HDR){
      waitTime = HDRsafetyDelay;
    }
    else{
      waitTime = safetyDelay;
    }       
       
    //take a picture
      digitalWrite(wakepin, HIGH);   //turn wakeup/focus on
      
      delay(wakeup);                 //keep focus
      
      digitalWrite(wakepin, LOW);    //turn wakeup off
      
      delay(wakewait);               //wait
      
      digitalWrite(shutterPin, HIGH);

      delay(waitTime);

      digitalWrite(shutterPin, LOW);
      count++;
   
    //display picture number
    if (sleeping){
      displayOFF();
      }
    else{
      displayDEC(count);
    }
    
    //wait the user-set interval
    if (minute){
      minuteMultiplier = 60;
    }
    else{
      minuteMultiplier = 1;
    }

      intervalCounter = 0;
      while((intervalStep*intervalCounter) < (((interval*1000)*minuteMultiplier)-(2*waitTime)) && start){
        delay(intervalStep);
        intervalCounter++;
      }
       
    //if the timelapse is to be stopped (or is finished), reset the counter to prepare it for the next timelapse.
    if (!start || count == numPics){
      displayDEC(interval);
      count = 0;
      start = false;
      digitalWrite(startLEDPin, start);
    }
  }      
}


////////////////////////////////////////////
//////Other Functions///////////////////////
////////////////////////////////////////////

//function to check the state of the start button and change the variables/LED state correspondingly
void checkStart(){
  if (!changeNumPics){
  activityTime = millis();
  if (sleeping){
    sleeping = false;
    displayDEC(count);
  }
  else{
  //if (millis() - pressStartTime > debounceDelay){ **debounce handled by hardware.
    start = !start;
    digitalWrite(startLEDPin, start);
    //pressStartTime = millis();
  //}
  }
  }
}

second half

//function to check the state of the up button and increment interval accordingly.
void checkUp(){
upReading = digitalRead(upPin);
if (upReading == HIGH && prevUpReading == LOW && millis() - pressUpTime > debounceDelay){
activityTime = millis();
if (changeNumPics){
if (numPics >= 9950){ //allows variable to wrap around.
numPics = 0;
}
else{
numPics += 50;
numPicsChanged = millis();
}
}
else{
if (interval >= 999){
interval = 0;
}
else{
interval += 1;
}
}
pressUpTime = millis();
}
prevUpReading = upReading;
}

//function to check the state of the down button and increment interval accordingly.
void checkDown(){
downReading = digitalRead(downPin);
if (downReading == HIGH && prevDownReading == LOW && millis() - pressDownTime > debounceDelay){
activityTime = millis();
if (changeNumPics){
if (numPics <= 0){ //allows variable to wrap around.
numPics = 9950;
}
else{
numPics -= 50;
numPicsChanged = millis();
}
}
else{
if (interval <= 0){
interval = 999;
}
else{
interval -= 1;
}
}
pressDownTime = millis();
}
prevDownReading = downReading;
}

//function to display a 3 digit number on 7-segment displays.
void displayDEC(int i){
for (byte bitMask = 128; bitMask > 0; bitMask >>= 1){
digitalWrite(clockPin, LOW);
digitalWrite(serialOnesPin, bitMask & ~digits[i%10] ? HIGH : LOW);
digitalWrite(serialTensPin, bitMask & ~digits[(i/10%10)] ? HIGH : LOW);
digitalWrite(serialHundsPin, bitMask & ~digits[i/100] ? HIGH : LOW);
digitalWrite(clockPin, HIGH);
}
}

//function to display "inf" on 3 7-segment displays.
void displayINF(){
for (byte bitMask = 128; bitMask > 0; bitMask >>= 1){
digitalWrite(clockPin, LOW);
digitalWrite(serialOnesPin, bitMask & ~inf[2] ? HIGH : LOW);
digitalWrite(serialTensPin, bitMask & ~inf[1] ? HIGH : LOW);
digitalWrite(serialHundsPin, bitMask & ~inf[0] ? HIGH : LOW);
digitalWrite(clockPin, HIGH);
}
}

void displayPIC(){
for (byte bitMask = 128; bitMask > 0; bitMask >>= 1){
digitalWrite(clockPin, LOW);
digitalWrite(serialOnesPin, bitMask & ~pic[2] ? HIGH : LOW);
digitalWrite(serialTensPin, bitMask & ~pic[1] ? HIGH : LOW);
digitalWrite(serialHundsPin, bitMask & ~pic[0] ? HIGH : LOW);
digitalWrite(clockPin, HIGH);
}
}
void displayINT(){
for (byte bitMask = 128; bitMask > 0; bitMask >>= 1){
digitalWrite(clockPin, LOW);
digitalWrite(serialOnesPin, bitMask & ~intvl[2] ? HIGH : LOW);
digitalWrite(serialTensPin, bitMask & ~intvl[1] ? HIGH : LOW);
digitalWrite(serialHundsPin, bitMask & ~intvl[0] ? HIGH : LOW);
digitalWrite(clockPin, HIGH);
}
}
void displayOFF(){
for (byte bitMask = 128; bitMask > 0; bitMask >>= 1){
digitalWrite(clockPin, LOW);
digitalWrite(serialOnesPin, HIGH);
digitalWrite(serialTensPin, HIGH);
digitalWrite(serialHundsPin, HIGH);
digitalWrite(clockPin, HIGH);
}
}

///////////////////////////////////////////[

for (byte bitMask = 128; bitMask > 0; bitMask >>= 1){
    digitalWrite(clockPin, LOW);
    digitalWrite(serialOnesPin, HIGH);
    digitalWrite(serialTensPin, HIGH);
    digitalWrite(serialHundsPin, HIGH);
    digitalWrite(clockPin, HIGH);
  }

That's a pretty roundabout way of doing eight iterations. In the absence of comments, any particular reason?

the code dont fit

probably because there's too much of it.

not sure y its like that.
its a code that i found on the net.
im new so only know the very basics.
if you know a better way im all ears.

Where did you find that code, because that is a LOT of code.
Do you have a link?

sadly i did not keep the link.
guess i should have.

Could you retrace your steps?

For now, all you need to show is whether or not a number of inputs work.
So, write a small sketch that does just that, using known I/O mechanisms, like Serial.print.

thanks ill try that.

warrenf:
other thing you should probly know is that i made a boo boo and stuck 9v threw the 5 inputs this is y im trying to use the analog input.
silly me.
and the transistor i changed to a relay
and also tried to add in a wake up funtion for the camera with a second relay.

so i may well have messed this whole thing up.

Quite possibly. A relay and a transistor are not usually interchangeable. What you're trying to do does not sound especially hard, but the picture you posted shows a fairly complex circuit, and I don't know whether you're getting even the basics right let alone wiring up things like that correctly.

the cct worked.
problems came after i put the 9v battery in the wrong side.
now i just cant get the analogs to work.

Ok you have the pull down resistor wired correctly, I'm assuming.

You don't need to make them analog unless your reading varying voltages, or resistances, I mean it will work, but you don't need it.

Just for now make the buttons and switches, digital, that way all you need to see is if it is HIGH or LOW.

ok. all the digital pin are being used. and the origanal 5 that were the switches are damaged. this is y im using analog.

Ok but, I just want you to test the buttons and switches without anything else on the arduino. When you know for sure that everything is working ,you can move them the analog pins. You need to see if you get either 1 or 255 when it is HIGH, and 0 for LOW

You could do a very simple ASCII "logical analyser".
Set all I/O pins (except pins zero and one!) to be inputs in "setup()", and enable their pullups.
In "loop()", digitalRead every pin and Serial.print its value as one or zero, and at the end of "loop()", call "Serial.println()" so all the results are on a single line.
As the program is running, simply ground a pin at a time, and check that the display in the serial monitor reflects this.
This program shouldn't be more than a dozen or so lines.

hey guys thanks for the advice i did the serialwrite thing to check if its picking up the inputs. and when i run the simple sketch it picks up all the buttons .
but when i put the end cct together it will not pick up the start stop button. but picks up all the others?
any ideas?