Show Posts
Pages: 1 ... 90 91 [92] 93 94 ... 236
1366  Using Arduino / Programming Questions / Re: Arudino UNO and CHR-6d IMU on: November 09, 2013, 06:57:25 am
How do you know that the code is not working ?
What do you expect it to do ?
1367  Community / Bar Sport / Re: Purpose of millis() timer on: November 08, 2013, 05:20:17 pm
Thanks
1368  Community / Bar Sport / Re: Purpose of millis() timer on: November 08, 2013, 04:48:08 pm
Quote
millis() is not used in the servo sweep example.
Did I ever say it was?
As this thread is about millis() I took it that was what you meant.

Quote
Quote
BlinkWithoutDelay seems to be OK
As I said, last time I looked, it wasn't.
The comparison was incorrect.

Edit: < fires up PC > yup, version 1.0.5 is still wrong.
Wrong in what way ?
1369  Community / Bar Sport / Re: Purpose of millis() timer on: November 08, 2013, 01:58:54 pm
BlinkWithoutDelay seems to be OK
Code:
  if(currentMillis - previousMillis > interval) {
millis() is not used in the servo sweep example.
1370  Community / Bar Sport / Re: Purpose of millis() timer on: November 08, 2013, 11:32:27 am
Quote
Why can't it just admit its true nature and go up by exactly 1 unit every 1024 us?
Then it wouldn't be a millis counter, would it ?  How would you use it to measure say a 10 second period ?  One way would be to adjust for the odd 24 us every now and again.  Wait a minute.  We just invented the millis() function !

Quote
I really don't like millis() because its rollover time is long enough to lure people into a false sense of security. At least with micros() you don't get to bury your head in the sand for a month and a half. This makes code easier to debug.
Most people who use millis() for timing will have picked up the idea from example code, such as BlinkWithoutDelay or from a forum like this so will use the subtraction method of determining the elapsed time which does not have a problem with rollover. 

It sounds like you are very bitter about millis() and have some bad experiences with it.  Would you care to share them ?
1371  Using Arduino / Programming Questions / Re: LED glowing instead of blinking and Serial.println issue on: November 08, 2013, 11:13:41 am
Code:
  else{
    digitalWrite(ledPin, LOW);
Serial.println (" Celsius, within the normal body temperature range");
}
}
This code is outside of the loop() function.
1372  Community / Bar Sport / Re: Purpose of millis() timer on: November 08, 2013, 09:33:44 am
It reports how many milliseconds have elapsed since the Arduino was last started or reset, but I suspect that you already knew that.

It's rollover period is much, much longer than micros().  Approximately 50 days as opposed to approximately 70 minutes.  Of course, neither is a problem as long as code is written correctly.

Have you a reference to it skipping numbers and the effect(s) that it has ?

Removing millis() from the Arduino source code might not affect any Arduino functionality directly but it would certainly screw up the many programs that use it.
1373  Using Arduino / Programming Questions / Re: problem with tcs230 sensor and servo on: November 08, 2013, 05:45:22 am
Those if/else blocks are weird.  They should be like this
Code:
if (this is true)
{
  // do Thing A
}
else if (that is true)
{
  // do Thing B
}
else
{
  // do Thing C
}

1374  Using Arduino / Programming Questions / Re: How to create an char array from a number of byte types? on: November 07, 2013, 07:33:46 am
Quote
i wan't to create an char array/string composed out of several diffident digits
I know that it is unfair to pick on problems probably caused by the use of a foreign language, but I like the idea "diffident digits".  Too shy to show their real value perhaps ?
1375  Using Arduino / Programming Questions / Re: Fill with zeros a number? on: November 07, 2013, 07:16:34 am
Picky, picky  (smiley)  but correct, of course in respect of the global variable.
I was focussing on not committing the sin of returning a pointer to a variable that was local to the function and missed the blindingly obvious.
1376  Using Arduino / Programming Questions / Re: Fill with zeros a number? on: November 07, 2013, 02:58:18 am
Code:
char numberBuffer[30];    //adjust to suit maximum length used

void setup()
{
  Serial.begin(115200);
  for (int length = 0; length < 21; length ++)
  {
    Serial.print(length);  //debug print
    Serial.print("\t");    //debug print
    Serial.println(formatForPrint(123, length));
  }
}
void loop()
{
}

char* formatForPrint(int number, int length)
{
  char formatBuffer[6];    //enough room for a length up to 99 characters (%099d)
  sprintf(formatBuffer,"%%0%dd",length);
  Serial.print(formatBuffer);    //debug print
  Serial.print("\t");            //debug print
  sprintf(numberBuffer, formatBuffer, number);
  return numberBuffer;
}
NOTE that numberBuffer is a global variable and not local to the formatBuffer function
1377  Using Arduino / Programming Questions / Re: Fill with zeros a number? on: November 06, 2013, 02:45:55 pm
Don't worry.  No offence taken.
1378  Using Arduino / Programming Questions / Re: output format question - XML? on: November 06, 2013, 01:49:55 pm
So, am I getting the right idea here?

Can you please post a sample of the XML produced by this code ?
1379  Using Arduino / Programming Questions / Re: Fill with zeros a number? on: November 06, 2013, 01:44:47 pm
The code works for numbers within the rang 0..999

try the code with a number that is longer or a negative and you see some point to improve the function.
Quite right.  I had meant to point that out in my reply.

In practice I would probably not use such a function in my code as it only replaces two lines with one in the main code and I would feel more in control of the formatting by having the sprintf on the line before the print instead of hidden in a function.  It would also become more and more difficult to extend the function to handle other formats properly.
1380  Using Arduino / Programming Questions / Re: Servo + RF comunication on: November 06, 2013, 12:47:51 pm
What errors would those be ?
Pages: 1 ... 90 91 [92] 93 94 ... 236