Show Posts
Pages: 1 ... 40 41 [42] 43 44 ... 68
616  Using Arduino / Programming Questions / Re: don't load the code on: December 09, 2012, 03:21:25 am
Hello, yes post all your code (as an attachment to your reply), and which Arduino model do you use?
617  Using Arduino / Programming Questions / Re: Converting floating point to a string, most efficient way? on: December 09, 2012, 03:14:55 am
Go in <arduino install folder>/hardware/tools/avr/avr/, here you have a lib folder: make a copy (or a zip) of it, as a backup.

Download the file I linked, open it, select all the files in it and drag and drop in that lib folder. It will ask you to replace files and folders, click Yes to All and it's ready, now you can use %f etc in sprintf and sscanf smiley
618  Using Arduino / Displays / Re: ITDB02 TFT LCD module is not sensing touch on: December 09, 2012, 01:44:32 am
I see your problem...sorry to tell you that, but you can't use the touch feature with the "ITDB02 Arduino shield v2.0" :



There is not enough pins on the Arduino UNO to enable both SD card reader and Touchscreen...

You should have purchased an Arduino Mega and the Mega shield smiley-sad

619  Using Arduino / Programming Questions / Re: Moving from one value to another on: December 09, 2012, 01:19:12 am
Hello and welcome smiley

I think you need to use a "swap" function:
Code:
void swap( int &a, int &b )
{
   int c = a;
   a = b;
   b = c;
}

...

if ( a > b )
{
  swap( a, b );
}

It will then be easier to handle a and b in a single for loop smiley
620  Using Arduino / Programming Questions / Re: 4x3 led grid array function? on: December 09, 2012, 12:50:41 am
Yes, it's possible with an array, but you could do something like that, instead of an array for each mode, have a single integer:

Code:
// the pins where each led is connected, in reverse order
const uint8_t LED_Pins[] = { 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };

// set a mode using a single int
const uint16_t MODE_1 = 0b111101101111; // this is your example (middle LEDs OFF) in one line
 
void SetLEDArrayMode( uint16_t mode )
{
  for (uint8_t i = 0; i < 12; i++)
    digitalWrite( LED_Pins[i], bool( mode & (1 << i) ) );
}
 
void setup()
{
    SetLEDArrayMode( MODE_1 );
}

Note, the reverse order is because using this method, the bits are read in reverse order too. But if your modes are always "symmetrical", then the order of the pins array will have no importance.. smiley-cool
621  Using Arduino / Programming Questions / Re: How can I simplify this simple code? (Again...) on: December 08, 2012, 11:57:26 pm
Hello,

- you could use char arrays instead of the String class
- Serial buffer's size is 64 bytes only (for Arduino Mega, for some other boards it's 16 I believe)
- do not use delay() or blocking code such as your while loops, especially if the thing is a plane autopilot smiley

For non blocking Serial reads you can do something like that:
Code:
void loop()
{
  if ( Serial.available() > 0 )
  {
    static char input[64];
    static uint8_t i;
    char c = Serial.read();

    if ( c != '#' && i < 63)
      input[i++] = c;
    
    else
    {
      input[i] = '\0';
      i = 0;

      //process the input string here
      Serial.println( input );
    }
  }
}
622  Using Arduino / Displays / Re: ITDB02 TFT LCD module is not sensing touch on: December 08, 2012, 11:39:45 pm
Hello and welcome smiley,

Try with the UTFT and UTouch libraries:

http://www.henningkarlsen.com/electronics/library.php?id=51
http://www.henningkarlsen.com/electronics/library.php?id=55

You display model for UTFT will be ITDB28
623  Using Arduino / Programming Questions / Re: Converting floating point to a string, most efficient way? on: December 08, 2012, 11:28:04 pm
For enabling floats in sprintf (and sscanf) you can install this in \hardware\tools\avr\avr\lib (make a backup of that lib folder, and then extract and replace files): http://arduino.cc/forum/index.php?action=dlattach;topic=124809.0;attach=27144

Another option is to use dtostrf (I believe it's more efficient, and use much less memory than sprintf with FP enabled): http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#ga060c998e77fb5fc0d3168b3ce8771d42
624  Using Arduino / Programming Questions / Re: Check if GPS is within a polygonal area on: December 08, 2012, 06:23:12 am
Shall I make a reference to you(the maker) or the original code in my code somewhere?

Absolutely not to me, I didn't make this function and I don't know who did (it's probably older than the first computer) smiley

Karma++ to guix.....

Thanks smiley-wink
625  Using Arduino / Programming Questions / Re: Check if GPS is within a polygonal area on: December 08, 2012, 04:57:34 am
Good smiley
626  Using Arduino / Programming Questions / Re: Check if GPS is within a polygonal area on: December 08, 2012, 04:44:11 am
Quote
I see that you use printf and bool? I guess this is Serial.print command and a boolean? function?

Yes replace printf by Serial.print's if you need to. And "bool" or "boolean", same thing smiley
627  Using Arduino / Programming Questions / Re: Check if GPS is within a polygonal area on: December 08, 2012, 04:16:14 am
I made this simple, working example:

http://codepad.org/3EwobfpQ


In this example, the polygon looks like:

Code:
Y

^
|
|     A               B
|      /------------|
|     /             |
|    /______________|
|  D                  C
+--------------------------------------> X

     X  ;  Y
A { 3.0 ; 4.0 }
B { 7.0 ; 4.0 }
C { 7.0 ; 2.0 }
D { 2.0 ; 2.0 }
628  Using Arduino / Programming Questions / Re: Check if GPS is within a polygonal area on: December 08, 2012, 02:34:08 am
Helo and welcome smiley

See this website for a starting point : http://alienryderflex.com/polygon

You may find other, ready-to-use functions if you search a little more smiley
629  Using Arduino / Project Guidance / Re: Urgent Help with code for automating an aquaponics garden using Time/TimeAlarms on: December 07, 2012, 12:00:28 pm
Hello and welcome smiley

Read this topic, you are using an old library that wasn't updated for the new Arduino IDE

http://arduino.cc/forum/index.php?topic=66054.45

Good luck
630  Using Arduino / Programming Questions / Re: help with strtok() on: December 06, 2012, 01:18:19 pm
Hello,

I suggest you make your own function, similar to strtok but that it skips blocks of ",,"..Something like that:

http://codepad.org/5rWaj2iA
Pages: 1 ... 40 41 [42] 43 44 ... 68