Show Posts
Pages: [1] 2 3 ... 44
1  Using Arduino / Programming Questions / Re: Exiting a function on a key press. on: April 14, 2014, 04:02:20 am
Thanks Paul.

I am really having problems with the quirks of this language.

== vs =

{ } and their use sometimes.

and some other things which creep in now and then.

Yes, the if (time == 0) would be more correct.
The two curly brackets are left overs from older code.

I am now "stuck" with keeping the code in the menu blocks waiting for the right code to exit from them.
I think I have it right, but it probably not the best.
2  Using Arduino / Programming Questions / Re: Exiting a function on a key press. on: April 13, 2014, 04:55:33 pm
PaulS,

Thanks very much.

I had nearly got what you said in your post.  But with minor variations.

It is sort of re-assuring that I had come up with similar to what you suggested at the same time.

Mine is slightly different, but I think I will change it to how you said as it is better.

This is the block of code now:
Code:
void DISPLAY_TIME(int time)
{
  int d1;
  int d2;
 
  {
    d2 = time % 10;
    d1 = int(time/10);
  }

  digitalWrite(D1_Select,HIGH);
  display_number(d1);

  digitalWrite(D2_Select,HIGH);
  display_number(d2);

  if (time = 0)
  {
    //  Turn off the display.
    digitalWrite(D1_Select,LOW);
    digitalWrite(D2_Select,LOW);
  }
  return;  //  Needed?
}
//==================================================================
int display_number(int digit)
{
  if (digit == 0)
  {
    digitalWrite(Di1,LOW);
    digitalWrite(Di2,LOW);
    digitalWrite(Di3,LOW);
    digitalWrite(Di4,LOW);
  }
  if (digit == 1)
  {
    digitalWrite(Di1,HIGH);
Right?

Oh, is that return needed?

Boguz,
Yes, I have a Canon 550d.
I have just got and installed Magic Lantern.  Kind of overwhelming.
You may want to look at Trigger Trap too.  I am waiting for their new version.  (NOT the App.)
This is a kind of "in between" thing for me which is camera independent.

I'll PM you soon with some of the piccies.
3  Using Arduino / Programming Questions / Re: Exiting a function on a key press. on: April 12, 2014, 05:03:17 pm
Paul,

Thanks for the info.  I am not a full time programmer and so don't know the rules.

What I did do was make a basic flow chart and work from there.

The "display time" part was duplicated a few times and so I made that into it's own little block of code.
As with key scan.

I put them in UPPER CASE only because they were the names of the "functions" (or blocks of code) and for my benefit I put their names how I did.

Yeah, maybe not a good move for me if I want to become "one of the boys" at the IT department or write code for a job.

It isn't going to happen.  I'm too old and many MANY other things.

I have read a few of the "standards" on how naming works, but it is .....  confusing to me.  And honestly:  Does it really matter?
So long as the code works and is understandable - isn't that the important part?

Some people put the { at the end of the line and the } on a line by itself.
I find it hard to read as I can't see the { and } easily - except for the indents - but I have to "read around" that problem.
It is pointless me complaining.

I would like to know how you would make a "function" for the DISPLAY_TIME so the two blocks of code can be reduced.
I am wort of working on it, but it is early days.

In another piece of code I worked out how to use .[ ] at the end to make arrays and saved 600 bytes of code.
I was very pleased with my self for that.  It took a lot of work and effort.

The KEY_SCAN part:
Yeah, that is not nice.
Originally it was going to return simple values - like: 1, 2 , 3, 11, 12, 13 but I started to notice that in a couple of calls to it, I was adding 1, 10, or subtracting 1 or 10.

The code to get the key value and then act on it was long.
Code:
if (key_value == 1)
{

}
if (key_value == 10)
{

}
and so on.

As that was pretty well already done when the keys were scanned I decided to return the +1, +10, -1, -10 values.
I kept the global "key_value" just in case I did need it in future routines.

The code isn't finished.

I have since changed bits of the code and written more, but still not complete.
What I am doing is keeping the parts of code in different tabs as much as possible to help break it down.
Whether this is a good thing or not I am not sure, but for now it does help me with things, so I shall keep doing it.

Hope to hear back with more helpful suggestions.  (Like the DISPLAY_TIME part.) Though I am looking at/working on it myself also.

This is a cut from the first part of what I have done to change it:
Code:
  if (gt == 0)
  {
    digitalWrite(D1_Select,HIGH);
  }
  if (gt == 1)
  {
    digitalWrite(D2_Select,HIGH);
  }
  if (digit == 0)
  {
    digitalWrite(Di1,LOW);
    digitalWrite(Di2,LOW);
    digitalWrite(Di3,LOW);
    digitalWrite(Di4,LOW);
  }

And so have basically halved the size of that part of the code.

Is that sort of what you were meaning?

4  Using Arduino / Programming Questions / Exiting a function on a key press. on: April 11, 2014, 07:17:19 pm
Folks,

I am writing a bit of code for my DSLR camera to help when doing "Light painting".

This is where I have the shutter open for 30 seconds and I am doing "second curtain flash".

All the fuss is because I see the problem of pressing the shutter button, getting to the subject and doing the light stuff all the while counting down from 30.

This little box does some of the work for me.

At this stage I don't have the RTC and may not really need it, but.....  Hey, It is an option.

Here is a walk through of what I want to happen:
The arduino boots, and it has 2 outputs to the camera.  One to "focus"/"wake up" the camera and one to take the picture.
It has 3 inputs - for now.  Two of the three start the sequence of taking the picture.
It has 2 x 7 Segment digits to count down and show time/s remaining.

On the arduino side of things:
3 pins for inputs.
4 pins for "7 segment display"
2 pins for digit selection (digit 1 and 2)
2 pins for the decimal points.
2 pins for the I2C bus if there is an RTC used.

I am using ClickButton to allow multiple functions from the 3 buttons/inputs.

I have really changed my way of writing code - included - from when I first started.
For the better?  Dunno.  But I am trying different ways and see which is better for me.

In the MENU / Set_Pre_time  it reads the "key" value for what is pressed.  One key increases the value, one decreases and the third "exits".

I'm stuck how to do that.  See code.

Sorry if it is a dumb question.
I have been out of the coding for a while and have forgotten bits of it and would appreciate a bit of help.

So to complete the walk through:
The arduino is waiting.

It seen either of the two inputs activate/trip/trigger/what ever.
It starts to count down and displays the time on the display.
While this is going on it looks and sees if a button is pressed.
If a button is pressed, it aborts taking the picture.
Otherwise it goes on, and takes the picture.
After that, it starts a count down from 30 (seconds and displays it on the screen/display.
Then it goes back to waiting.

I may include a bit of code so even after the photo has been started, if something goes wrong, I can reset the counter.
Academic for now, so I won't worry about it.


Also, in the "Display_Time" it is a bit .....   long (?) in how I did it.
It has to translate the value into the binary and send it out the pins.

Is there a trick how to make it a bit smaller?
"arrays"? for instance?

When you look at the code, the thing to load is called "V1".  (That to me is "Version 1" of the code.)

Thanks in advance.

5  Using Arduino / LEDs and Multiplexing / Re: TTL BCD-7 Segment display driver IC, problem on: April 04, 2014, 02:11:00 am
Thanks folks.

Given the 7448 (or 74LS48) I found at Jaycar.  Local electronics shop.

So now I have to do a bit or thinking about the sketch and "board" layout.

6  Using Arduino / LEDs and Multiplexing / Re: TTL BCD-7 Segment display driver IC, problem on: April 03, 2014, 04:14:23 am
I want to use 5 volts, so I looked in my TTL cookbook.  7447.  Ok, but it is for common ANODE displays.

What's on the next page, right after the 7447?

(BIG BLUSH!)

My TTL cookbook is a 1982 version.

So a 7448 is not listed.

Thanks.
7  Using Arduino / LEDs and Multiplexing / Re: TTL BCD-7 Segment display driver IC, problem on: March 29, 2014, 05:16:23 pm
Chuckle.

Yeah, I am trying to get my head around what you said.

Sorry, but I am a bit confused.

The brightness will be adjusted by using a PWM pin as the common.....  what ever.

Could I use a CMOS BCD-7 segment chip at 5V reliably?
8  Using Arduino / General Electronics / Re: LOW power HALT, battery and supplys. on: March 29, 2014, 05:12:59 pm
The power supply voltage is 12V DC.

The main parts of the circuit are 12V.

Thanks though.
9  Using Arduino / General Electronics / Re: LOW power HALT, battery and supplys. on: March 29, 2014, 03:11:41 am
The battery would be 4 x AAA batteries.  (6V)

Just enough to keep the arduino "Alive" and enough to operate a 5v relay to turn on the mains.

(See picture)

The rest of the circuit is BEFORE the 7805 - sorry realised the mistake after posting.

10  Using Arduino / General Electronics / Re: Measuring crystal frequency - HELP! on: March 29, 2014, 02:58:54 am
OK, maybe it is the caps go to GND.

The project is from a mag 2 years ago and it has been "Stalled" for a long time.

I measure 2.4 volts (DC) on each side to ground.

The crystal is pretty much:
cap to GND  and input of the PIC.
That is both pins.
Just walked over and looked at the PCB.

There aren't any more things connected to the crystal.

So it is funny that if I put the DMM across the crystal, suddenly it (the whole thing) seems to come to life.
11  Using Arduino / General Electronics / Measuring crystal frequency - HELP! on: March 29, 2014, 01:54:45 am
Not on an arduino project, but I would like some help.

I have a project with a 12Mhz crystal.

It is connected to two pins of the PIC and two capacitors going to +5v.

I have a handhelp scope (Jaycar) but am not sure how to get an output of the frequency.

I believe it is the input to the crystal and the common to Ground.

Correct?

Oh, and if someone could comment on what is going on, I'd like a bit of help.

When I plug it in to the USB port, NOTHING happens.  There are two LED's and they are off.
They should be on, but aren't.  Poking around with my DMM, I put the leads across the crystal.

Suddenly it came to life - the LED's came on.

I didn't have it plugged into the computer.  I had it plugged into a USB phone charger.

I am still to plug it into a computer and try again, but in the mean time I thought I could ask and maybe learn what is going on.

Thanks in advance.
12  Using Arduino / General Electronics / LOW power HALT, battery and supplys. on: March 29, 2014, 01:47:59 am
I Have heard that I can put the Arduino into "sleep mode which makes it REALLY low power consumption.

Being who I am, I thought I would have a power saving mode and have a SMALL battery to keep it alive.

The RTC has an alarm output pin which I can use to "wake up" the arduino, and it would then turn on the main power.

Then the output of the power supply would go through a 7805 to re-charge the battery and power the arduino, and the rest of the circuit.

Well, as the battery would be on the output of the 7805, I would need to have a diode on the output to stop the battery back feeding the 7805.

Alas there is a problem there that the 5 v would become 3.8 volts (or what ever it is.)

Thinking back, to get around this problem I put a diode (same as the one after the output) between the GND pin of the 7805 and GND which would offset the drop.

Right?

13  Using Arduino / LEDs and Multiplexing / TTL BCD-7 Segment display driver IC, problem on: March 29, 2014, 01:29:40 am
Folks,

I am building a project and I want 2 x 7 Segment displays.
To minimise pin usage, I thought I would use a BCD-7 Segment display driver.

I want to use 5 volts, so I looked in my TTL cookbook.  7447.  Ok, but it is for common ANODE displays.
It puts the outputs LOW to activate the segment.  Ok.   It also boasts that it can drive nixi and other kinds of displays.
If I want to use LED it is said to use 330 ohm resistors.

But looking at the 7 Segment displays they are common CATHODE!

So it won't exactly work.

How else can I do this?
Or what am I missing?

14  Using Arduino / General Electronics / Re: 4066 or 4016 to control canon camera shutter release. on: February 20, 2014, 04:34:09 pm
Thanks thanks thanks guys.

Very appreciated.

(I am kinda looking after a fish right now and it is difficult to know what he is feeling/doing.)

Anyway, I shall get going on the next phase.
15  Using Arduino / General Electronics / Re: 4066 or 4016 to control canon camera shutter release. on: February 20, 2014, 05:09:17 am
Coding,

The max fwd current of 60ma....  That's base, right?

So I = E/R.

If I do it for 50ma - which should be on strong enough - I just plug in the numbers for the resistor.
Pages: [1] 2 3 ... 44