Show Posts
Pages: [1] 2
1  Using Arduino / Project Guidance / Re: Blinking an LED but need delay too on: April 26, 2014, 06:06:23 am
Thanks for the replies everyone.

I don't need the code to do anything else, that is the whole sketch.

Thanks again.
2  Using Arduino / Project Guidance / Blinking an LED but need delay too on: April 23, 2014, 01:53:30 pm
Hi.

I'm not sure this will make sense but, here goes.

I need to blink an LED while there is a delay going on.
The delay needs to be there for a timing aspect of the sketch.
I know there is blink whithout delay but, I am using a delay.

I can get the sketch to work how i want by turning the LED on, waiting a second, then turning it off.
This works, I just wondered if there was a neater way that I could do the same thing.

Thank you.

Code:


    

#define RUN 2                   // Define the run/ stop switch pin.

#define LED1 13                 // Define the LED run indicator pin.
void setup() {
 
    pinMode(RUN, INPUT);        // Initialise the pin as an input.
    digitalWrite(RUN, HIGH);    // Set the pullup resister.
    pinMode(LED1, OUTPUT);      // Initialise the pin as an output.
    Keyboard.begin();           // Start keyboard emulation.
}

void loop() {
   
    while(digitalRead(RUN)) {}    // Stop the rest of the loop running until required.
   
    digitalWrite(LED1, HIGH);        // Turn the LED on.
    Keyboard.press(KEY_LEFT_ALT);    // Perform key press.
    Keyboard.press(KEY_TAB);         // Perform key press.
    Keyboard.releaseAll();           // Release all keys.
    delay(500);                      // Half second pause.
    Keyboard.press(KEY_F5);          // Perform key press.
    Keyboard.releaseAll();           // Release all keys.
    delay(1000);
    digitalWrite(LED1, LOW);        // Blink LED and pause for 10 seconds.
    delay(1000);
    digitalWrite(LED1, HIGH);
    delay(1000);
    digitalWrite(LED1, LOW);
    delay(1000);
    digitalWrite(LED1, HIGH);
    delay(1000);
    digitalWrite(LED1, LOW);
    delay(1000);
    digitalWrite(LED1, HIGH);
    delay(1000);
    digitalWrite(LED1, LOW);
    delay(1000);
    digitalWrite(LED1, HIGH);
    delay(1000);
    digitalWrite(LED1, LOW);
    delay(1000);
   
   
   
    }
   
   
   
 
 
3  Using Arduino / Programming Questions / Re: Problems Using If Statements on: December 09, 2013, 03:00:41 pm
Fair enough Jimmy, point taken and thank you.

The switch will be set before power on.
The delay will be set by the switch, powered on and remain on until the job is finished.

Thanks
Paul
4  Using Arduino / Programming Questions / Re: Problems Using If Statements on: December 09, 2013, 12:17:44 pm
Thank you all very much for your time, I really do appreciate it.

Unfortunately, being totally new to this, most of your answers mean very little to me I'm afraid.

With just little snippets of code, it's very difficult for me to work out what goes where.

Please don't take this as criticism or a complaint, I do greatly appreciate the time and trouble you have all taken to help me.

Thank you
Paul
5  Using Arduino / Programming Questions / Problems Using If Statements on: December 09, 2013, 09:11:54 am
Hi, hope someone can help please.

I'm making a small intervalometer for a DSLR and I want to be able to switch between six fixed values using a rotary switch.
I've never used IF statements before and i'm having trouble with them.

I'n the code below, when the loop gets to the IF statements at the bottom, it just ignores them completely.
Am I doing something wrong or, can't I use IF statements in this way.

Thanks
Paul
Code:
// Basic intervalometer for DSLR.

// Pins 4 and 5 connected to the camera cable via two optocouplers.

// Action 1 (FOCUS) is turned on for one second to allow the cama=era to auto focus.

// Action 2 (SHUTTER) is then turned on for one second to allow for the shutter to activate.

// The interval between shots is controlled by the six position switch and ground connected to pins 6 to 11.


#define FOCUS  4             // Define the Focus Pin as Digital Pin 4.             
#define SHUTTER  5           // Define the Shutter Pin as Digital Pin 5.         

#define ONESEC 6             // Define the six switch pins.
#define TENSEC 7
#define THIRTYSEC 8
#define SIXTYSEC 9
#define THIRTYMINS 10
#define SIXTYMINS 11


void setup()

{   
 
 // Initialise the Arduino data pins for OUTPUT.

  pinMode(FOCUS, OUTPUT);         // Initialise the Arduino data pins for OUTPUT.
  pinMode(SHUTTER, OUTPUT);
 
  pinMode(ONESEC, INPUT);         // Initialise the Arduino data pins for INPUT.
  digitalWrite(ONESEC, HIGH);     // Attach internal pull-up resistors.
  pinMode(TENSEC, INPUT);
  digitalWrite(TENSEC, HIGH);
  pinMode(THIRTYSEC, INPUT);
  digitalWrite(THIRTYSEC, HIGH);
  pinMode(SIXTYSEC, INPUT);
  digitalWrite(SIXTYSEC, HIGH);
  pinMode(THIRTYMINS, INPUT);
  digitalWrite(THIRTYMINS, HIGH);
  pinMode(SIXTYMINS, INPUT);
  digitalWrite(SIXTYMINS, HIGH);


}

 

 void loop()

{
   
 
   digitalWrite(FOCUS,HIGH);           // Turns optocoupler 1 on, activating the auto focus.

   delay(1000);                        // Wait 1 second.

   digitalWrite(SHUTTER,HIGH);         // Turns optocoupler 2 on, activating the shutter.

   delay(1000);                        // Wait 1 second

   digitalWrite(FOCUS,LOW);            // Turns optocoupler 1 off.
   
   digitalWrite(SHUTTER,LOW);          // Turns optocoupler 2 off.

   if (ONESEC == LOW) {                // Delays the loop a fixed time, depending on which switch pin is low.
     delay(1000);}
 
   if (TENSEC == LOW) {                // Delays the loop a fixed time, depending on which switch pin is low.
   delay(10000);}
   
   if (THIRTYSEC == LOW) {             // Delays the loop a fixed time, depending on which switch pin is low.
   delay(30000);}
   
   if (SIXTYSEC == LOW)  {            // Delays the loop a fixed time, depending on which switch pin is low.
   delay(60000);}
   
   if (THIRTYMINS == LOW) {           // Delays the loop a fixed time, depending on which switch pin is low.
   delay(1800000);}
   
   if (SIXTYMINS == LOW) {             // Delays the loop a fixed time, depending on which switch pin is low.
   delay(3600000);}

 }
6  Using Arduino / Project Guidance / Re: Timing Issues on: December 08, 2013, 01:43:41 pm
Woohoo!

That works perfectly.

Thanks very much to everyone.

Paul
7  Using Arduino / Project Guidance / Re: Timing Issues on: December 07, 2013, 02:14:06 pm
Hi Bill, thanks for the quick reply.

I just tried it and unfortunately it's just the same.

Thanks very much though, greatly appreciated I can assure you.

Paul
8  Using Arduino / Project Guidance / Timing Issues on: December 07, 2013, 01:31:19 pm
Hi, I wonder if someone could help me please?

I am builing a basic (for now) intervalometer for my DSLR.
I have it up and running and am pretty happy with it so far.
However, I am having trouble with varying the delay time using a pot.
I have mapped my pot value but keep getting strange readings and the loop freezes.
When I turn the pot above about half way, I start getting eratic negative values.
Could anybody tell me why this might be happening please?

I have included my code below.
I am a newb to this so please forgive my coding.

Thanks
Paul

Code:
// Basic intervalometer for DSLR.

// Pins 4 and 5 connected to the camera cable via two optocouplers.

// Action 1 (FOCUS) is turned on for one second to allow the cama=era to auto focus.

// Action 2 (SHUTTER) is then turned on for one second to allow for the shutter to activate.

// The interval between shots is controlled by the potentiometer.

// The potentiometer is connected to +5v, Gnd and Pin A0.



#include <Wire.h>            // Include the I2C Library.

#include <HTI2CLCD.h>        // Include the I2C-LCD Backpack Library.

HTI2CLCD lcd;                // Create an instance of the I2C-LCD Backpack.

const int  lcd_address=58;   // I2C Address of LCD backpack.

int bl=0;                    // Backlight power value.

#define FOCUS  4             // Define the Focus Pin as Digital Pin 4.             

#define SHUTTER  5           // Define the Shutter Pin as Digital Pin 5.         


int potpin0 = A0;    // Select the input pin for the potentiometer.
int pot0 = 0;        // Variable to store the potetiometer reading.

void setup()

{   
delay(200);                                  // Give LCD time to configure itself.
    Wire.begin();                            // join i2c bus (address optional for master).
    lcd.setType(lcd_address,2,16);           // Define rows and columns for LCD.
   
   
   
    lcd.clear(lcd_address);                  // Clear LCD.
    lcd.backLight(lcd_address,100);           // Set backlight to 100.
   
    // Display String
   
    lcd.print(lcd_address,"PR-DSLR ver1.0");  //Print splash info.
    delay(3000);
   
// Initialise the Arduino data pins for OUTPUT.

  pinMode(FOCUS, OUTPUT);       

  pinMode(SHUTTER, OUTPUT);


}

 

 void loop()

{

    pot0 = analogRead(potpin0);  // Reads the value of Pot.
   
    pot0 = map(pot0, 0, 1023, 1000, 60000);  // Maps the pot reading to a delay time.
   
    lcd.clear(lcd_address);                  // Clears the LCD.
    lcd.print(lcd_address,pot0);             // Displays the mapped pot reading (Range 1 second to 1 minute).
    lcd.print(lcd_address," Millisecs");     //Adds the word Millisecs after the mapped pot reading.
 
   digitalWrite(FOCUS,HIGH);           // Turns optocoupler 1 on, activating the auto focus.

   delay(1000);                        // Wait 1 second.

   digitalWrite(SHUTTER,HIGH);         // Turns optocoupler 2 on, activating the shutter.

   delay(1000);                        // Wait 1 second

   digitalWrite(FOCUS,LOW);            // Turns optocoupler 1 off.
   
   digitalWrite(SHUTTER,LOW);          // Turns optocoupler 2 off.

   delay(pot0);                       // Wait 15 seconds.

 }
9  Using Arduino / Project Guidance / Re: Opto-couplers and Arduino on: December 02, 2013, 03:13:02 pm
That's brilliant, thank you very much.
I think I should be fine on the output side, I just didn't want to feed the optos anything they couldn't handle.

Thanks again.
Paul
10  Using Arduino / Project Guidance / Opto-couplers and Arduino on: December 02, 2013, 02:33:19 pm
Hi, I wonder if anybody can help me please.

I'm hoping to make a trigger unit for my DSLR.
Eventually, I want it to do all sorts of complicated things but for now, I just need to know that the hardware works.
I will be controlling focus and shutter from two Arduino pins. I would like to isolate the camera using optocouplers. I have never used them before so would like a little help please.

They are ILD74 optocouplers.
Here is the data sheet http://www.farnell.com/datasheets/6513.pdf.

I'm not great with data sheets but, I assume I'll need a current limiting resister, is this correct?

Thanks in advance for any help.

Paul
11  Using Arduino / Displays / Re: display with few free digital pins on: March 17, 2012, 08:12:21 am
I use this little fella:

http://www.hobbytronics.co.uk/i2clcd-backpack

It uses the I2C bus, just analog pins 4 and 5 plus a ground and 5volts.
It's really easy to use and comes with it's own library.
Instead of the pins that came with it, I soldered a 16 pin socket to the board.
That way I can just clip any display to it.
I'm quite the novice but it's very easy to use.

Paul
12  Using Arduino / General Electronics / Re: Arduino headers - Uk supplier? on: March 11, 2012, 08:15:32 am
If you're making shields up or need something longer to work with breadboard, these stackables come in really handy.

http://www.hobbytronics.co.uk/arduino/arduino-stackable-header-kit

http://www.oomlout.co.uk/extra-pieces-headers-c-70_89.html

Paul
13  Using Arduino / Project Guidance / Re: Using an FTDI cable on: August 30, 2011, 03:48:48 pm
Hi, thanks for that.
Yes, everything is wired up correctly.
When I upload with the Uno (either via jumper wires or actually placing the chip in the Uno) everything works perfectly.
The chips are bootloaded. I even have both Uno and Duemilanove bootloaders on different chips. Neither of which want to work.

Thanks for that Shellycat.
I'll check that out, thank you!

Thanks
Colaboy
14  Using Arduino / Project Guidance / Using an FTDI cable on: August 30, 2011, 02:01:40 pm
Hi.
Is there a knack to programming a standalone chip using an FTDI cable?
I have tried allsorts and I just can't upload a sketch no matter what I try.
I can upload one just fine using my Uno, taking the chip out and using jumper wires.
I know the cable is working as it is a recognised com port and when attached to a working chip, it sends serial data back and forth.
I think I read somewhere that the timing of pressing reset is crucial. I have approached this in a very methodical manner(timing, gaps etc.) but to no avail.
As the Uno sorts the reset out for me but the FTDI cable doesn't, I think this may very well be the problem.

Any ideas?

Thanks in advance.
Colaboy
15  Using Arduino / Project Guidance / Re: Very Small Arduino on: August 18, 2011, 10:21:10 am
Wow!
Thanks for all the info gang.

Lots to take in and mull over.

I will weigh up my options and decide which way to go.

Thanks again, much appreciated I can assure you.

Paul
Pages: [1] 2