Show Posts
Pages: 1 [2] 3 4 ... 230
16  Using Arduino / Programming Questions / Re: do this to any variable that equals y, do that to any variable that equals x on: September 15, 2014, 09:23:44 pm

Would using the OR operator be preferable to using an array variable?

With two variables, the OR operator is preferable. As the number increases, arrays start to become more preferable.

Is there something equivalent to the following psuedo code:

No
17  Using Arduino / Programming Questions / Re: Loading a long int into an array on: September 15, 2014, 09:19:58 pm
Use modulus division and a for loop to extract the actual bytes. Take 3512, for example:

Code:
3512 % 10 = 2
3512  / 10 % 10 = 1
3512 / 10 / 10 % 10= 5
3512 / 10 / 10 / 10 % 10 = 3

Once a divide by 10 results in a 0, you can start printing blanks.
18  Using Arduino / Programming Questions / Re: do this to any variable that equals y, do that to any variable that equals x on: September 15, 2014, 09:11:30 pm
hmm. I guess i need to be more specfic. Ill update my original post.

No need, the proper answer has already been posted. You have to check if each of them equal the specified value, using the or operator.
19  Using Arduino / Programming Questions / Re: Unable to get the results in Serial monitor on: September 15, 2014, 06:57:36 pm
Code:
  int fs = 400;
  float Ts = 1/fs;

1 / 400 equals 0 according to integer math. If you don't want it to do integer math, force it to do floating point math:

Code:
  int fs = 400;
  float Ts = 1.0/fs;
20  Using Arduino / Programming Questions / Re: Calculations returning float on: September 15, 2014, 06:54:32 pm
Still returns a float. Waste of resources

What? It's going to return a float regardless of what you assign it to. If you don't want it to return a float, don't divide it by a float.
21  Using Arduino / Programming Questions / Re: Calculations returning float on: September 15, 2014, 06:41:06 pm
Whats the difference to a int or uint as you suggested!?
Again, one is signed, and one isn't signed.

Quote
I don't need the sign, so what does that change the float to a non float!?

No, it changes it to a signed int. If you want to change it to an unsigned int, then make result of type unsigned int.

If you're asking what the difference between something like uint16_t and unsigned int is, there isn't a difference on the Arduino.
22  Using Arduino / Project Guidance / Re: Beginner need help for project combining Xbee, Barcode scanner and 7segments on: September 15, 2014, 06:10:30 pm
What have you got so far? Do you have the hardware? Have you any software?
23  Using Arduino / Programming Questions / Re: Calculations returning float on: September 15, 2014, 06:08:46 pm
But an int and a uint16_t aren't the same thing?

They take up the same amount of space, but they aren't the same thing. One is signed, one isn't.
24  Using Arduino / Programming Questions / Re: Can't read/write to EEProm chip on: September 15, 2014, 06:07:29 pm
Does anyone have any clue to what I'm doing wrong?

So far, I'll we've got is "it doesn't work" and a page number to a book we may or may not have. Going to need more information than that.
25  Using Arduino / Programming Questions / Re: Variable question - way to code 'all variables except' ? (using []?) on: September 15, 2014, 06:05:59 pm
Can you have a FLOAT variable also be a BYTE to save space?

No. An 8 bit float would hardly be usable in just about any application.
26  Using Arduino / Programming Questions / Re: Calculations returning float on: September 15, 2014, 06:03:01 pm
I just want to return the integer of that division,

So cast it to an int:

Code:
(int) (acceleration/1.85)

or better yet, since you're trying to do that calculation a half dozen times, assign the result of the division to an int:

Code:
int result = acceleration/1.85;

and then compare result.
27  Using Arduino / Programming Questions / Re: SRAM memory usage on Arduino Uno on: September 15, 2014, 05:34:25 pm
Quote
If I increase message[], there is no SRAM memory usage change shown.

Because you're not using message[], so the compiler is optimizing it out.
28  Using Arduino / Programming Questions / Re: Calculations returning float on: September 15, 2014, 05:26:46 pm
Too large to post.

But not too large to attach.

Will this help?

Nope. We have no idea how those variables are being declared and how you've determined that you're "getting a floating point result when diving them"
29  Using Arduino / Programming Questions / Re: NEWBIE: Building code to monitor in the background. on: September 15, 2014, 05:23:27 pm
Code:
if(currentMillis - previousMillis > interval) {  // interval is 360000 (6 minutes)
   previousMillis = currentMillis;  
   digitalWrite(36,HIGH);                //   This will turn the chem pump on 36 will be the pin
}
 if( currentMillis - previousMillis2 > interval2){  //interval 2 is 30000 (30 seconds)
   previousMillis2 = currentMillis;
  digitalWrite(36,LOW);
}

interval is a variable. It can changed, like being set to 6 minutes or 30 seconds. You just have to keep track of what state the pump is currently set to, in order to know what interval should be set to.
30  Using Arduino / Programming Questions / Re: break; not working in while(1) loop on: September 15, 2014, 05:17:52 pm
Get rid of all the commented out code, put curly braces on separate lines and use the Arduino IDE's auto format tool to fix the indenting. You don't want people who can help you taking one look at it and thinking "the hell with this, I'm not weeding through that code."
Pages: 1 [2] 3 4 ... 230