Show Posts
Pages: 1 ... 125 126 [127] 128 129 ... 302
1891  Using Arduino / Programming Questions / Re: Float precision 6-7 digits, is it 6 or 7? on: March 16, 2013, 12:49:40 am
Try with negatives.
1892  Using Arduino / Programming Questions / Re: Wait for real end of serial transmission on: March 15, 2013, 08:32:08 pm
So it's pretty quick until you have more string than hardware buffer?

Wow. I write Serial.available() driven routines... if I want the most responsive code doing much text-out it would make sense to manage what I feed Serial when, on a BlinkWithoutDelay scale.  smiley-lol

1893  Using Arduino / Programming Questions / Re: Wait for real end of serial transmission on: March 15, 2013, 08:19:19 pm
Does flush() block?

1894  Using Arduino / Programming Questions / Re: sprintf with two char buffers >> not working? on: March 15, 2013, 08:16:00 pm
Preferably a small sketch that only runs in setup(). This one's got to be easy.
1895  Using Arduino / Programming Questions / Re: Accessing serial data stored in a buffer using a char pointer ? on: March 15, 2013, 08:13:12 pm
And I'll toast ya with ale next time I'm down at Big Jim's. It's cups there but at least it's ale.

1896  Community / Bar Sport / Re: Your latest purchase on: March 15, 2013, 08:05:30 pm
Another reason I like my Teensy 2.0's, they do pay towards the project and cost less even w/pins.

But mostly it's about AVR w/USB including a Mega2560-class version.
I don't even try to solder pins to those after I &%@$-ed up one of their micro-SD adapters.
1897  Using Arduino / Programming Questions / Re: Float precision 6-7 digits, is it 6 or 7? on: March 15, 2013, 04:50:09 pm
It's IEEE floating point. Count on 6 places and sometimes 1 will be .9999999.

If you're good with numbers and remember the by-hand ways then you can achieve more accuracy using 32 and 64 bit integer fixed-point --- in general faster than using floats on AVR-based Arduinos.

Really, 9 places with type long and 19 places with type long long.

My suggestion is if you want like meters to 6 places then use micrometers as your unit and only print the decimal point for human use.

There are ways to use integers to get greater range but since I don't need them I forget the details. Try looking up the Big Number library just for fun, number of places is arbitrary and may be as large as you have RAM and time.

Here's more than you want to know about floating point:
http://introcs.cs.princeton.edu/java/91float/
1898  Using Arduino / Programming Questions / Re: Switch-case loop problem?! on: March 15, 2013, 04:17:08 pm
First, let me say; You've done a good job utilizing loop() and timers correctly. It's like fresh air not to be typing "learn BlinkWi....".

But in this case I think you've overdone it with the control variables. It needs to be simpler.

Code:
 case 1:
      if( millis() - prag_tm1 > 3000) // this keeps being true
    {
      flag_tm1 = 1;
    }
    if( millis() - prag_tm2 > 10000) // even when this is true
    {
      flag_tm2 = 1;
      var = 0;
    }
  break;

You have 1 variable for gate to go up and another for gate to go down.
And then here you have the gate-up variable being set every time after 3 seconds.

I suggest that you have twice the control variables and timers that you need.
Just use one gate movement variable with 0=no move, 1=up, 2=down.
Just use one timer. Where do they ever get set different?
Increase the number of states that var can have to 2 and break up case 1 into 2 cases.

Possibly use 1 control variable with more than 3 states to combine var and the gate control.

Possibly in a block of comments, outline the action in steps and use pseudocode as needed to make the needed steps clear. You can check your code against that.


1899  Using Arduino / Programming Questions / Re: Accessing serial data stored in a buffer using a char pointer ? on: March 15, 2013, 03:43:34 pm
And a Happy Saint Patrick's Weekend to ya! Drink a Jameson's for me, willya?

One thing, just to make sure as I'm not. Make buffer[], and any arrays and variables referred to by different functions as global by defining them right up near the top above setup() even. A static inside loop() should not be visible outside loop().
1900  Using Arduino / Project Guidance / Re: infrared sensor connecting to computer on: March 15, 2013, 10:20:32 am
That's different. Use IR leds and detectors. Put the detectors in tubes or behind apertures or both.
Cost should be small.

1901  Using Arduino / Project Guidance / Re: infrared sensor connecting to computer on: March 15, 2013, 09:15:54 am
With light, a simple pair of beams to interrupt your player would not be able to aim to break.

With IR light you might be able to make two 'fans' of IR and try to catch the reflection as the ball passes through. I do say "try" because I give this almost no chance to work.

It would be much simpler to listen for the hand to hit the ball and the ball to hit the wall and compute with speed of sound and distances (player to wall, player to mic, wall to mic) data.

1902  Using Arduino / Project Guidance / Re: Reflective surface, alternatives to mirrors? on: March 15, 2013, 08:46:17 am
Aluminum cans are plated on the outside, generally very shiny to highlight the painted label. With paint remover and fine steel wool the label comes off and you are left with beautiful shine. Coors cans are highly silver under the label. Some few others will be brass color. I know this from modeling, the metal can be flattened and polished up nice. Not a mirror but yes reflective.

You could also look for chromed steel, even junk. A little polish and some work, pazow, mirror!

1903  Using Arduino / Programming Questions / Re: Keyboard output(Bit of a beginner) on: March 15, 2013, 08:36:03 am
If you are running Windoze then Hyperterminal can be used to send PC keystrokes directly to Arduino. Hyperterminal will also let you copy contents to the clipboard for paste elsewhere.

 
1904  Using Arduino / Programming Questions / Re: Accessing serial data stored in a buffer using a char pointer ? on: March 15, 2013, 08:25:17 am
You can set a char * to the start of a char array:

char buffer[ 32 ];
char *buf = buffer;

You can index the pointer:
buf++; // move 1 byte to the next char, if it was an int pointer it would move 2 bytes to the next int
buf--; // you can go back

You can do pointer math:
buf += 8;
buf -= 2;

You can use string (not C++ String object but C string.h) commands to set pointers to say...
find a character withing a string or a string within a string or to parse a string.

There's too many to list here when they're listed and explained elsewhere:
http://www.nongnu.org/avr-libc/user-manual/group__avr__string.html

You can treat pointers as variable memory addresses.

A valid C string ends with a NULL ( == 0 ) character.


1905  Using Arduino / Programming Questions / Re: IF temperature > 24 --> hot hot hot on: March 15, 2013, 12:21:54 am
Try reading the first post again.

Pages: 1 ... 125 126 [127] 128 129 ... 302