Show Posts
Pages: 1 ... 36 37 [38] 39 40 ... 79
556  Using Arduino / Programming Questions / Re: Compiler optimization of while() conditions on: September 19, 2013, 02:16:53 pm
I suggest you put a comment that you really do want to do an assignment in a logical condition. 99.99% of the time this construct is a typo where == was intended.
557  Using Arduino / Programming Questions / Re: How to return and error in constructor? on: September 18, 2013, 01:37:19 pm
"Or, don't...."

Oops, my C is showing.  errno, anyone?

You could create an error condition variable in the class and use a getError() method to read it.

Is that better?

Though the start method idea is better.
558  Using Arduino / Programming Questions / Re: How to return and error in constructor? on: September 18, 2013, 12:25:09 pm
Set a global variable to an error condition.

BTW, it would do no good to tell main() that there is an error, since you never get there with an arduino.
559  Using Arduino / Programming Questions / Re: Significant digits mysteriously appearing when converting from int to float on: September 18, 2013, 12:22:01 pm
And please stop misusing the term "significant digits" the noise at the end is past signifigance.
560  Using Arduino / Programming Questions / Re: Significant digits mysteriously appearing when converting from int to float on: September 18, 2013, 11:39:32 am
Check out the questions about floating point in the C Programming FAQ, especially:
http://c-faq.com/fp/fpequal.html
561  Using Arduino / General Electronics / Re: 7812 and TIP122 on: September 17, 2013, 05:28:55 pm
The 7812 is a 12 V regulator. The TIP122 is an NPN bipolar power transistor. You would need to add other components to make it a regulator.

Get thee to a datasheet!
562  Using Arduino / General Electronics / Re: Completely confused about MOSFETs on: September 17, 2013, 01:57:49 pm
The drain has to be more positive than the source. You are conducting current through the Drain-Body diode.
563  Using Arduino / Programming Questions / Re: Do While with Char[] test on: September 12, 2013, 05:55:45 pm
No, what I am saying is that you read a character and put it in profName[i].
You print profName[i]. Great you got it!
*you increment i* with i++
Then you test i on the incremented i, so that profName[i] is pointing to garbage.

Moderator edit: Italics removed, indices restored.
564  Using Arduino / Programming Questions / Re: Do While with Char[] test on: September 12, 2013, 05:49:41 pm
It looks to me that your i++ is incrementing past the test for '.'
565  Using Arduino / Programming Questions / Re: how can I make a switch activate a variable? on: September 12, 2013, 05:35:14 pm
Remember, in C and C++ assignment operators are not special at all.

and while

selection-selection;

is useless because it does not do anything

selection - selection++;

 is not useless, though it does no more than

selection++;

would.
566  Using Arduino / Project Guidance / Re: communication with arduino on: September 12, 2013, 04:35:14 pm
If it is something that needs to survive a power cycling, you might want to see about storing it in EEPROM.
567  Using Arduino / General Electronics / Re: multistage amplifiers- plz help on: September 12, 2013, 10:50:15 am
I am partial to a cascode, myself.
568  Using Arduino / Programming Questions / Re: signed-unsigned char help on: September 11, 2013, 10:41:23 am
Totally Off Topic:

I thought the big retrospective mistake was the logical operator precedence:
http://www.lysator.liu.se/c/dmr-on-or.html
569  Using Arduino / Programming Questions / Re: add number to long int on: September 10, 2013, 03:56:52 pm
Code:
if (sv < 10) {
  sv = sv+10;
} else if (sv < 100) {
  sv = sv+100;
} else if (sv < 1000) {
  sv = sv+1000;
} else if (sv< 10000) {
// ...
} else {
  sv = sv + 1000000;
}
[\code]
570  Using Arduino / Programming Questions / Re: add number to long int on: September 10, 2013, 02:28:41 pm
Not quite, Delta_G.
The comma operator "A pair of expressions separated by a comma is evaluated left to right, and the type and value of the result are the type and value of the right operand." (From K&R)

So, sensorcode will equal (mySwitch.getReceivedValue()).
Pages: 1 ... 36 37 [38] 39 40 ... 79