Show Posts
Pages: [1] 2 3 ... 44
1  Using Arduino / Programming Questions / Re: How can I break the outer loop? on: April 19, 2014, 05:53:02 pm
Thanks all.  I didn't mean to stir up a big conversation. 

The code is looking through a big matrix.  In the real code it is 4 dimensional so there are 4 levels of nested loop in the search structure.  When I find the first match I leave and I want to know the "coordinates" of the match I found (so the missile lands on target smiley  ) or that all of the iterators are at their maximum value so no match was found.  I had thought of the solution in Pauls first response and it seemed logical but bulky.   There is more code after the conditional so I'd have to set the boolean and then call break to break the innermost loop.  That sounds easy enough. 

I was just wondering if I had found the elusive "one use" for the goto. 
2  Using Arduino / Programming Questions / How can I break the outer loop? on: April 19, 2014, 02:44:20 pm
Let's say I have nested for loops like this :

Code:
int i;
int j;

for(i = 0; i<100; i++) {
     for(j = 0; j<100; j++{
     // do something with i and j...
    if (some condition of i and j and some other variable) {
         
            //How can I break both loops right here?

}
}
}

   // So I can land right here with the values of i and j that match up with my condition...



In the code I'm working on, I'm actually four levels nested, so whatever solution has to be simple.  I'm tempted to put a label at the end of the nested block and use the dreaded goto.  Is there a better way?
3  Community / Website and Forum / It says I'm banned??? on: April 17, 2014, 04:09:59 pm
When I try to login from my laptop, I get a message that says I've been banned as a spammer.  But when I login from my desktop at home I'm fine.  I've tried clearing cookies and all the usual stuff.  Any idea what might be going on?
4  Using Arduino / Programming Questions / Re: Switch and Case question on: April 17, 2014, 01:24:32 pm
Right.  The value in the variable doesnt automagically track the pot.  It only changes when your code explicitly changes it. 
5  Using Arduino / Programming Questions / Re: Switch and Case question on: April 17, 2014, 10:43:22 am
Youre wrong about the while loop.  Youre right that it will exit if val0 ever goes below 500 but val0 will never do that since you never read the pin again.  If val0 was over 500 and you never set it to anything else then how will it magically ever get below 500?  Youll be stuck in that while loop forever. 
6  Using Arduino / Programming Questions / Re: true false help? if (!variable){} on: April 16, 2014, 12:05:48 pm
If you print true, it is true you get a 1.  But that doesnt mean 1 is true and 0 is false.  Actually it is 0 is false and anything that is not 0 is true.
7  Using Arduino / Programming Questions / Re: Does my Arduino ignore its serial buffer? on: April 01, 2014, 08:18:03 pm
You're making a classic mistake.  You check that there is a byte to read in the serial buffer then try to read a whole bunch of them.  Serial data comes slow, much much slower than your Arduino executes code.  So you get a byte and you read it and it is an A and you go to parseInt but the number hasn't shown up yet. 

You should either check to make sure all of your characters have arrived by checking Serial.available against a larger number or restructure the code to just check the serial buffer each time through the loop and hang on to what it's got until it gets a complete message and only act once it has processed the whole thing. 
8  Using Arduino / General Electronics / Re: another soldering quesition - perhaps incorrect use of flux? on: March 28, 2014, 08:22:22 pm
2) Clean the tip of my iron and drop just a little bit of solder onto the end to get some fresh tinning/solder blob on it. 

I've tried this, but haven't gotten it to work yet.  I've cleaned the tip with flux, and I clean it with the sponge.  I let the iron get hot.  When I apply the solder to the tip, the solder doesn't flow onto the tip.  It just bunches up into a ball at the end of the length of solder in my hand.

My soldering iron seems to repel solder.

This same thing happens to me.  I've looked at all the tutorials and they make it sound so easy, just touch the tip to the solder and now on to the next step...

I need a video maybe.  Or maybe one of us should make a video of what happens to us and someone can try to explain what we're doing wrong. 
9  Using Arduino / Programming Questions / Re: help with significant figures on percentages on: March 22, 2014, 06:13:27 pm
I think you don't understand significant figures.

A percent with two digits as an integer like 15% or 43% has exactly 2 significant figures. 

Your statement that you want all the sig figs that you can get tells me you really don't know anything about sig figs.  The number of sig figs available to you is a consequence of the inputs and not the calculation.  You don't get to pick and choose.  If you want more sig figs coming out then you have to give more sig figs going in. 
10  Using Arduino / Programming Questions / Re: Use another pin like pin 13 on: February 27, 2014, 03:28:48 pm
I tryied to use a 10k resiston on the output and plugged on pin 2 but dont worked

What do you mean?  One end of the resistor went to pin 2, got that.  Where was the other end of the resistor connected?
11  Using Arduino / Programming Questions / Re: Use another pin like pin 13 on: February 27, 2014, 01:29:10 pm
I would guess it's because 13 has the built in LED and maybe that is sort of acting like a weak pull-down.

Either way, it sounds like it's time to learn about pull-up and pull-down resistors.
12  Using Arduino / Programming Questions / Re: Problem with return tangent of x on: February 27, 2014, 10:19:41 am
Code:
a=tan(double(x/y));

Since you've defined tan to be nothing, this will condense down to:

Code:
a=(double(x/y));

And since x and y are integers and x is smaller than y the answer here will be 0.  And that's what you're getting.
13  Using Arduino / Programming Questions / Re: Problem with return tangent of x on: February 27, 2014, 10:18:04 am
Code:
double; a=tan(double(x/y)); //a= tan^-1 (x/y) , exprimé en degrés (la fonction donne un angle en radians)

What's the double with the semicolon doing at the beginning?  I think that should go away.

Was it meant to be a cast?  That's not how you do a cast.
14  Using Arduino / Programming Questions / Re: Coding an XOR on: February 25, 2014, 11:10:58 pm
If you had something like ^^ for boolean XOR couldn't it end up becoming really ambiguous? 

A && B && C      makes sense
A || B || C       makes sense

A XOR B XOR C          WTF???
15  Using Arduino / Programming Questions / Re: Boolean Variables on: February 20, 2014, 07:10:22 pm
figitalRead --  returns TRUE if someone fidgets with the pin?
Pages: [1] 2 3 ... 44