Show Posts
Pages: 1 [2]
16  Using Arduino / Project Guidance / Re: analog input issuses on: December 11, 2012, 02:35:43 pm
the code dont fit
so here is the first half

Code:
//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();
  //}
  }
  }
}
17  Using Arduino / Project Guidance / Re: analog input issuses on: December 11, 2012, 02:34:18 pm
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.





18  Using Arduino / Project Guidance / analog input issuses on: December 11, 2012, 01:33:20 pm
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?
Pages: 1 [2]