Show Posts
Pages: 1 ... 24 25 [26] 27 28 ... 40
376  Using Arduino / Programming Questions / Re: Time lapse controller, swapping delays for timed functions on: June 13, 2012, 10:40:39 am
OK thanks for the advice.

Will this method work... I don't for a minute expect it to be the 'proper' way of doing it. I'm at work so won't be able to test anything until later this evening

I expect it will just stay in the while loop until the time has elapsed?

Thanks again

(the rest of the code is the same)

Code:
//Trigger focus
        timer1 = millis();
        digitalWrite(focusPin, HIGH);

      while (millis() - timer1 > focusDelay)
      {
        //hold focus button down and do nothing else for x seconds
      }

      
      //Trigger shutter
      timer1 = millis();
      digitalWrite(shutterPin, HIGH);
      digitalWrite(shutterLED, HIGH);
      
      while (millis() - timer1 > (expose * 1000))
      {
        // Hold open shutter for x seconds
      }
  

      digitalWrite(shutterPin, LOW);
      digitalWrite(shutterLED, LOW);
      digitalWrite(focusPin, LOW);
377  Using Arduino / Programming Questions / Re: Time lapse controller, swapping delays for timed functions on: June 13, 2012, 06:18:21 am
haha, well... Is there an intermediate option?  smiley-razz

I'd like to learn how to do it, but I'm new to programming as a whole and it has taken a long time to get the (mess) of code working that I have written.

I just cant picture how it could be structured, I was thinking you would set a variable to 0 then set to millis() and examine it each time through the loop, but the structure that I have currently got I don't think it could work?

thanks all
378  Using Arduino / Programming Questions / Time lapse controller, swapping delays for timed functions on: June 12, 2012, 07:11:08 pm
Hi all, I have been working on a time lapse controller for my DSLR for a couple of weeks. I have got it working OK and I have just added motor control for using a slider using a modded servo. The code is very messy and with lots of spaces here and there but I find it helps me navigate while I'm working on stuff.

I use delays for the intervals so obviously I am jamming up the processor which id rather not so I can do other things.

I have been pondering for the last couple of days over how to change the delays for timed functions but no success yet. I just cant think how it would be done, I need to toggle a pin, wait for time x, then toggle another pin, wait for time y, then turn toggle both pins at the same time, then toggle another pin high, wait for time z, then toggle it again - without re-writing a lot of my code

any help would be good smiley

edit.. code seems to big to post, although i didn't think it was that big!
http://shedbass.com/dtokez/Time_lapse_2_2.ino
379  Community / Exhibition / Gallery / Re: grovercam.com Interactive website on: June 12, 2012, 08:23:01 am
really well put togther project! well done, I'm hoping I get a chance to feed him soon smiley
380  Using Arduino / Installation & Troubleshooting / Re: Programming using silabs chip usb-ttl converter on: June 09, 2012, 06:33:05 pm
after numerous attempts, I connected the grounds up and it works smiley
381  Using Arduino / Project Guidance / Re: LCD reset, or how do I get a non flashing display? on: June 08, 2012, 08:56:13 am
I always try to avoid using clear(), like you say the flickering becomes annoying unless you are doing it slowly. I just print info onto, with enough empty spaces to cover up any chars that might not be used on the new data to print
382  Using Arduino / Installation & Troubleshooting / Re: Programming using silabs chip usb-ttl converter on: June 06, 2012, 06:19:58 am
Ok I'll try that later when I'm home, thanks bud
383  Using Arduino / Installation & Troubleshooting / Re: Programming using silabs chip usb-ttl converter on: June 05, 2012, 07:28:46 pm
switching the connections, rx tx etc does not seem to solve it smiley-sad

I have just looked into the DTR function, I think you are correct about the rst being an internal reset. Looking at the chips datasheet DTR is pin 28, but it does not look like they have broken it out on this board. I have soldered a wire and cap to the pin and it now resets the board fine and at the right point, but I'm still getting no data transmission? I'm wondering if it's faulty?

Thanks all
384  Using Arduino / Installation & Troubleshooting / Re: Programming using silabs chip usb-ttl converter on: June 04, 2012, 06:44:03 pm
Hi, no luck with a cap in series with reset smiley-sad is there anything else I could try?

I'm noticing the data LED in the dongle is not lighting up at all?
385  Using Arduino / Installation & Troubleshooting / Re: Programming using silabs chip usb-ttl converter on: June 02, 2012, 06:44:47 pm
Ok thanks Nick, I'll see if I can find one to try
386  Using Arduino / Installation & Troubleshooting / Re: Programming using silabs chip usb-ttl converter on: June 01, 2012, 08:14:28 pm
Hi Nick, I mean RST on the arduino and the RST pin on the programmer - as per this pin out
387  Using Arduino / Installation & Troubleshooting / Programming using silabs chip usb-ttl converter on: June 01, 2012, 06:33:24 pm
hi all, I have just got one of the following http://www.ebay.co.uk/itm/300587914146?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649 installed the drivers all seems ok, but can't load code onto a 328p. I can load the code using my uno fine. This converter does not seem to put my chip in reset so the upload fails?

I've connected tx to tx, rx to rx, rst to rst and gnd to gnd but no luck?
388  Using Arduino / Programming Questions / Re: Help with a problem using while and if statements together on: May 28, 2012, 07:30:19 pm
Thanks guys, got it going now. Great tutorial, it really helped. I'm just reading the pin only in the while loop now as you suggest smiley

next step is to get rid of the delays and use a counter so I can do other tasks such as update the display, should be fun trying to get that working!
389  Using Arduino / Programming Questions / Re: Help with a problem using while and if statements together on: May 27, 2012, 08:07:16 pm
Thanks Mark, I still can't get it work - currently the final while while loop gets ignored and the program goes back to the start. Not sure what I'm doing wrong?

Code:
#include <LiquidCrystal.h>


//Pin naming
int focusPin = 2;
//int focusLED = 13;
int shutterPin = 4;
int shutterLED = 13;
int enterButton = A2;
int pauseButton = A1;
int LDRPin = A5;      // Analog input pin that the lDR is attached to
int LCDBackLight = 3;      // Analog (PWM) output pin that the BACKLIGHT is attached to
int amountPot = A4;
int intervalPot = A3;


//Parameters
int focusDelay = 800;
int shutterDelay = 800;
//int interval = 20000;
int maxInterval = 600000; //Max interval between shots in millis allowed
int maxAmount = 1000; //Maxium amount of shots allowed

const int minLight = 40;        // at or below this light level, use minimum backlight intensity
const int maxLight = 900;        // at or above this light level, use maximum backlight intensity
const int minBacklight = 20;      // lowest backlight intensity to use
const int maxBacklight = 255;    // highest backlight intensity to use

int LDRRead = 0;         // value read from the LDR
int outputValue = 0;     // value output to the PWM (analog out)

int intervalRead = 0;         // value read from the interval pot
int amountRead = 0;         // value read from amount of photos pot

int interval = 0;
int amount = 0;





// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {

  //Set up LCD
  lcd.begin(16, 2);
  delay(100);

  //Set up pins
  pinMode(focusPin, OUTPUT);
  pinMode(shutterPin, OUTPUT);
  pinMode(shutterLED, OUTPUT);
  pinMode(LCDBackLight, OUTPUT);
  pinMode(enterButton, INPUT);
  pinMode(pauseButton, INPUT);


  //enable pull ups on buttons
  digitalWrite(enterButton, HIGH);
  digitalWrite(pauseButton, HIGH);


}


void loop(){


  int shots = 0;

  // LDR controlled LCD backlight via PWM part
  int sum = 0;
  for (int i=0; i<16; i++) // take 16 samples from the analog input
  {
    sum += analogRead(LDRPin);
  }
  LDRRead = sum/16; // divide by the amount of samples for the average value

  // map it to the range[0..255] of the analog output that the LCD backlight it connected to
  outputValue = LDRRead/4;   // alternative to map function for scaling down from analog input
  outputValue = map(constrain(LDRRead, minLight, maxLight), minLight, maxLight, minBacklight, maxBacklight );

  // change the analog out value to adjust LCD backlight intensity
  analogWrite(LCDBackLight, outputValue);   



  // read interval from pot
  intervalRead = analogRead(intervalPot);
  interval = map (interval, 0, 1023, 0, maxInterval);

  // read amount from pot
  // amountRead = analogRead(amountPot);
  //amount = map (amount, 0, 1023, 0, maxAmount);

  amount = 10;


  lcd.setCursor(0,0);
  lcd.print("Shots:");
  lcd.print(amount  );

  lcd.setCursor(0,1);
  lcd.print("Delay:");
  lcd.print(interval  );


  int bval;

  bval = digitalRead(enterButton);


  //if the enter button is pressed, execute the following loop
  if (bval == LOW)
  {
    //run though the shutter loop until the number of shots has been reached
    while (shots < amount)
    {

      // LDR controlled LCD backlight via PWM part
      int sum = 0;
      for (int i=0; i<16; i++)
      {
        sum += analogRead(LDRPin);
      }
      LDRRead = sum/16;
      outputValue = LDRRead/4; 
      outputValue = map(constrain(LDRRead, minLight, maxLight), minLight, maxLight, minBacklight, maxBacklight );
      analogWrite(LCDBackLight, outputValue);


      lcd.setCursor(0,0);
      lcd.print("Shots:");
      lcd.print(amount);
      lcd.print("/");
      lcd.print(shots + 1  );

      //Trigger focus
      digitalWrite(focusPin, HIGH);
      delay(focusDelay);

      //Trigger shutter
      digitalWrite(shutterPin, HIGH);
      digitalWrite(shutterLED, HIGH);
      delay(shutterDelay);
      digitalWrite(shutterPin, LOW);
      digitalWrite(shutterLED, LOW);
      digitalWrite(focusPin, LOW);

      delay(interval + focusDelay + shutterDelay);

      lcd.clear();
      shots++;
    }
    //display message on the lcd and wait for enter button press
    digitalRead(enterButton);
    while (enterButton == HIGH)
    {
      lcd.setCursor(0,0);
      lcd.print(shots);
      lcd.print(" Shots taken");
      digitalRead(enterButton);
    }

  }


  //if enter button has not been pressed, do nothing and keep waiting
  if (bval == HIGH)
  {
    //do nothing
  }


}

390  Using Arduino / Programming Questions / Re: Help with a problem using while and if statements together on: May 27, 2012, 06:54:21 pm
Hi, thanks. That's true pretty illogical of me not to think of just putting it after  smiley-razz

I must be doing something else wrong, because now it sits in the final while loop and the message stays on screen when the enter button is pressed?

Code:
#include <LiquidCrystal.h>


//Pin naming
int focusPin = 2;
//int focusLED = 13;
int shutterPin = 4;
int shutterLED = 13;
int enterButton = A2;
int pauseButton = A1;
int LDRPin = A5;      // Analog input pin that the lDR is attached to
int LCDBackLight = 3;      // Analog (PWM) output pin that the BACKLIGHT is attached to
int amountPot = A4;
int intervalPot = A3;


//Parameters
int focusDelay = 800;
int shutterDelay = 800;
//int interval = 20000;
int maxInterval = 600000; //Max interval between shots in millis allowed
int maxAmount = 1000; //Maxium amount of shots allowed

const int minLight = 40;        // at or below this light level, use minimum backlight intensity
const int maxLight = 900;        // at or above this light level, use maximum backlight intensity
const int minBacklight = 20;      // lowest backlight intensity to use
const int maxBacklight = 255;    // highest backlight intensity to use

int LDRRead = 0;         // value read from the LDR
int outputValue = 0;     // value output to the PWM (analog out)

int intervalRead = 0;         // value read from the interval pot
int amountRead = 0;         // value read from amount of photos pot

int interval = 0;
int amount = 0;





// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {

  //Set up LCD
  lcd.begin(16, 2);
  delay(100);

  //Set up pins
  pinMode(focusPin, OUTPUT);
  pinMode(shutterPin, OUTPUT);
  pinMode(shutterLED, OUTPUT);
  pinMode(LCDBackLight, OUTPUT);
  pinMode(enterButton, INPUT);
  pinMode(pauseButton, INPUT);


  //enable pull ups on buttons
  digitalWrite(enterButton, HIGH);
  digitalWrite(pauseButton, HIGH);


}


void loop(){


  int shots = 0;

  // LDR controlled LCD backlight via PWM part
  int sum = 0;
  for (int i=0; i<16; i++) // take 16 samples from the analog input
  {
    sum += analogRead(LDRPin);
  }
  LDRRead = sum/16; // divide by the amount of samples for the average value

  // map it to the range[0..255] of the analog output that the LCD backlight it connected to
  outputValue = LDRRead/4;   // alternative to map function for scaling down from analog input
  outputValue = map(constrain(LDRRead, minLight, maxLight), minLight, maxLight, minBacklight, maxBacklight );

  // change the analog out value to adjust LCD backlight intensity
  analogWrite(LCDBackLight, outputValue);   



  // read interval from pot
  intervalRead = analogRead(intervalPot);
  interval = map (interval, 0, 1023, 0, maxInterval);

  // read amount from pot
  // amountRead = analogRead(amountPot);
  //amount = map (amount, 0, 1023, 0, maxAmount);

  amount = 10;


  lcd.setCursor(0,0);
  lcd.print("Shots:");
  lcd.print(amount  );

  lcd.setCursor(0,1);
  lcd.print("Delay:");
  lcd.print(interval  );


  int bval;

  bval = digitalRead(enterButton);


  //if the enter button is pressed, execute the following loop
  if (bval == LOW)
  {
    //run though the shutter loop until the number of shots has been reached
    while (shots < amount)
    {

      // LDR controlled LCD backlight via PWM part
      int sum = 0;
      for (int i=0; i<16; i++)
      {
        sum += analogRead(LDRPin);
      }
      LDRRead = sum/16;
      outputValue = LDRRead/4; 
      outputValue = map(constrain(LDRRead, minLight, maxLight), minLight, maxLight, minBacklight, maxBacklight );
      analogWrite(LCDBackLight, outputValue);


      lcd.setCursor(0,0);
      lcd.print("Shots:");
      lcd.print(amount);
      lcd.print("/");
      lcd.print(shots + 1  );

      //Trigger focus
      digitalWrite(focusPin, HIGH);
      delay(focusDelay);

      //Trigger shutter
      digitalWrite(shutterPin, HIGH);
      digitalWrite(shutterLED, HIGH);
      delay(shutterDelay);
      digitalWrite(shutterPin, LOW);
      digitalWrite(shutterLED, LOW);
      digitalWrite(focusPin, LOW);

      delay(interval + focusDelay + shutterDelay);

      lcd.clear();
      shots++;
    }
    //display message on the lcd and wait for enter button press
    bval = digitalRead(enterButton);
    while (bval == HIGH)
    {
      lcd.setCursor(0,0);
      lcd.print(shots);
      lcd.print(" Shots taken");

    }

  }


  //if enter button has not been pressed, do nothing and keep waiting
  if (bval == HIGH)
  {
    //do nothing
  }


}












Pages: 1 ... 24 25 [26] 27 28 ... 40