Show Posts
Pages: 1 [2] 3 4 ... 303
16  Using Arduino / Project Guidance / Re: Inconsistent values with Bluetooth and Serial.Read on: April 18, 2014, 06:37:44 pm
They use some kind of packet system with its own ECC?
17  Using Arduino / Programming Questions / Re: Where am I going wrong with the no delay method? on: April 18, 2014, 11:10:32 am
in your void flash, instead of
Code:
interval = analogRead(0)/10; //read pot value, divide by 10 to reduce range of flash sweep speed
  if (interval <5) // delays of less that 5 create too fast of a flash sweep. Set to minimum of 5
  {
    interval = 5;
  }
you could maybe map the value, like this you can easily control it's min and max values. No need for that if statement.

You do know that min and max use the same basic code if not more?
18  Using Arduino / Programming Questions / Re: Calculating slope using array issues on: April 18, 2014, 11:07:36 am
I should have taken more time on that.
19  Using Arduino / Programming Questions / Re: Sketch on Mini w/328 only runs once on: April 18, 2014, 11:05:09 am
Quote
You do know that the Mini may have some differences as to pin numbers (and is there a led?) from say, the UNO?
No it doesn't. It's the same 328P chip. Only difference is that some promini's support A6/A as analog inputs.


My UNO board has a pin map just to tell board pins from 328 pins.

Does the Mini have the built-in led and resistor on pin 13?
20  Using Arduino / Programming Questions / Re: Where am I going wrong with the no delay method? on: April 18, 2014, 11:01:19 am
If you use unsigned integers then the only accounting for rollover is that you have a maximum longest interval regardless of when it starts.

Unsigned integer rollover requires no difference in code when you handle it properly in the first place.

if ( Unsigned_Now - Unsigned_Start >= Unsigned_Interval ) {}; // ALWAYS WORKS REGARDLESS OF ROLLOVER

The only times you need "rollover code" is when you don't do the unsigned subtraction or you don't use unsigned math (or manage to klutz it up in some more convoluted way).
21  Using Arduino / Programming Questions / Re: Sketch on Mini w/328 only runs once on: April 18, 2014, 10:52:27 am
You do know that the Mini may have some differences as to pin numbers (and is there a led?) from say, the UNO?
http://arduino.cc/en/Main/ArduinoBoardMini

If you can't get this sketch to run it may be due to those very differences:
Code:
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);   
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

There could be power issues for all I know.
22  Using Arduino / Programming Questions / Re: Where am I going wrong with the no delay method? on: April 18, 2014, 10:41:29 am
Perhaps you would be better served by getting help understanding BlinkWithoutDelay first...
because it's pretty clear that you don't.
23  Using Arduino / Programming Questions / Re: Calculating slope using array issues on: April 18, 2014, 10:23:57 am
Really good coding practices don't leave the possibility of a crash.

Murphy was an optimist.
24  Using Arduino / Programming Questions / Re: How to grab responses from Serial Terminal? on: April 18, 2014, 09:16:12 am
If you hadn't posted here then I wouldn't even know about these boards yet.
25  Using Arduino / Programming Questions / Re: How Can I Serial print a sensor value each minute with out delay. on: April 18, 2014, 09:14:14 am
And to help you with future coding, maybe check out all the sections in the link below that have Operator in the name.
http://arduino.cc/en/Reference/HomePage

There's patterns to them as well as differences but they're all very useful.
26  Using Arduino / Programming Questions / Re: Calculating slope using array issues on: April 18, 2014, 09:02:42 am
To fix this, you can cast either the numerator or the denominator of the fraction as float, like this:
Code:
 float slope = (float)(readings[1]-readings[0])/(readings[3]-readings[2]);
A purist might cast both as float.

Excellent guys thank you very much for the help, it's now giving me the accuracy I was looking for. Appreciate the other feedback too. The serial print is showing the correct number but if readings are equal to zero then 'nan' or 'inf' are printed, I take it this is due to me not dealing with the issue of zero value reading as you guys mentioned. I've tried to figure it out but I'm not having much joy so maybe one of you guys could help with this?

Thanks

That is going to give you a float of the finished integer operation inside the parens.
1/5 would give 0.0 not 0.2.
You need to divide float by float not int by int.

As noted above, you need to check for divide by 0 and perhaps return a very large value for slope.
27  Using Arduino / Programming Questions / Re: How Can I Serial print a sensor value each minute with out delay. on: April 18, 2014, 12:29:12 am
Code:
 if(currentMillis - previousMillis == interval) {

This is an error waiting to happen. Maybe not in this code on this Arduino but keep using that and you'll see.

What error? Well, what happens if the exact milli where that is true is missed for any reason? That error.
28  Using Arduino / Programming Questions / Re: How to grab responses from Serial Terminal? on: April 18, 2014, 12:25:05 am
It really helps to tell up front about hardware, especially when you're using a non-standard board.
I looked up the BLUNO and it appears that there is no USB to PC on it, that the radio uses Serial instead.

I see a switch to go between AT commands and Normal Serial and scratch my head over that.
That board has its own peculiarties. I'm sure the reasons are good but those have to be understood anyway.
29  Using Arduino / Programming Questions / Re: Calculating slope using array issues on: April 18, 2014, 12:02:43 am
Code:
float slope = (readings[1]-readings[0])/(readings[3]-readings[2]);

The readings[] values are all stored as ints and unless you tell the compiler to use them differently the math done on the right hand side of the = will be done as ints. You tell the compiler how by using a cast and remember that inside of parens is a little domain where casts outside only get applied after being operated on.

Code:
int A = 1;
int B = 5;
Serial.println( A/B ); // prints 0

float C;
C = (float) A / (float) B; // C now == 0.2 or very close, floats are "funny" that way.

(float) above is the cast. Verb of cast is casting. "Casting" is short for "type casting".

Mixing data types without specifying how they are to interact is the cause of lots of hair loss and not just for newbs.
30  Using Arduino / Programming Questions / Re: How Can I Serial print a sensor value each minute with out delay. on: April 17, 2014, 11:39:05 pm

the = is what i believe is was missing right before the interval


Of course! How could anybody have missed that? What "="?

Perhaps it was your detailed and specific questions that threw me?
Pages: 1 [2] 3 4 ... 303