Show Posts
Pages: 1 ... 90 91 [92] 93 94 ... 274
1366  Using Arduino / Programming Questions / Re: Arduino and Notepad++ on: January 28, 2014, 11:36:41 am
Quote
I have to save the sketch in Notepad++ before uploading to my board.
Which is exactly what LarryD suggested.
1367  Using Arduino / Programming Questions / Re: A helping hand required - Noob needs some sketching advice.. on: January 28, 2014, 11:30:01 am
Code:
  while(Tank_Purge >= Tank_Empty && Tank_Purge !=0);
  {
    Tank_Purge=Tank_Purge ++;
    delay(100);
}
 
I have removed the lines that were commented out in order to make things clearer, but it seems to me that this while loop is going to take some time to execute because the only thing that is changing is the Tank_Purge variable and that only increments 10 times per second anyway.  What is the purpose of this loop ?

Incidentally
Code:
Tank_Purge=Tank_Purge ++;
is more conventionally written as
Code:
Tank_Purge++;
1368  Using Arduino / Programming Questions / Re: program language on: January 28, 2014, 06:52:12 am
Quote
I'm a newbie here and i did not yet browse all blogs here.
Search the forum for PIR and you will get more hits than you can cope with.
1369  Using Arduino / Programming Questions / Re: A helping hand required - Noob needs some sketching advice.. on: January 28, 2014, 05:40:38 am
I do not have time to help improve your code, but I love this comment.  Does the code do what it says ?  smiley
Quote
   // *** Initialize Pins so relays are inactive at reset. To Ensure unexpected operation during reboot.
1370  Using Arduino / Programming Questions / Re: Coding for an Autonomous garden navigating robot using on: January 28, 2014, 05:33:20 am
Quote
What I'm actually thinking is to move forward for like 1 second after the pump action and run forward again and this time trying to detect with the collision sensor.
It will detect the obstruction immediately because that is why it stopped in the first place.  After watering it needs to turn before moving forward again.  Depending on the type of sensor used it may need to back off before turning.

How will the robot identify the places to stop and water as opposed to say a fence or a wall ?
1371  Using Arduino / Programming Questions / Re: Formatting GPS "heading" value? on: January 28, 2014, 05:26:44 am
The maximum angle of XXX.XX is 6 characters long so, allowing for the final NULL on the string the buffer needs to be 7 characters long (or more).  The parameters look OK to me.

Using strings instead of Strings would not necessarily make the program more efficient but the memory fragmentation that Strings can cause could be important in larger programs.

Here is something to get you going.
Code:
void setup()
{
  Serial.begin(115200);
  outputAngle(1.45);
  outputAngle(12.45);
  outputAngle(123.45);
}

void loop()
{
}

void outputAngle(float angle)
{
  char anglebuff[7];
  char outputbuff[10];

  dtostrf(angle, 4, 2, anglebuff);

  if (angle < 100 && angle > 9.999)
  {
    strcpy(outputbuff, "0");
    strcat(outputbuff, anglebuff);
  }
  else
    if (angle < 10)
    {
      strcpy(outputbuff, "00");
      strcat(outputbuff, anglebuff);
    }
    else
    {
      strcpy(outputbuff, anglebuff);   
    }
  Serial.println(outputbuff);
}
1372  Using Arduino / Programming Questions / Re: Formatting GPS "heading" value? on: January 28, 2014, 02:39:57 am
The anglebuff array needs to be large enough to hold the target string plus the terminating NULL character so a dimension of 4 will not be large enough.  It may work as it is but you will be writing to memory locations beyond the array as declared which could cause all sorts of problems.

Two other observations.
You are using a mix of Strings and strings which is generally considered a bad thing.  Strings (capital S) have proponents here and they seem generally easier to use than strings (lower case s) at first sight.  However, C style strings (NULL terminated char arrays) are generally felt to be a better way to do things in the limited memory environment of a micro-controller.

If the angle is less that 100 you add one leading zero but if it is less than 10 you still only add one leading zero.
1373  Using Arduino / Programming Questions / Re: Libraries? on: January 28, 2014, 02:09:49 am
You could put the code in the library, or a version of it, in your program but it would make the code unwieldy and messy to read and you would need to find it and copy/paste it in each time that it was required.  The same goes for the Arduino functions such as pinMode, Serial.print etc.  Think what a bind it would be to have to put the code for those in every program.
1374  Using Arduino / Project Guidance / Re: Noob needs assistance on: January 28, 2014, 02:05:44 am
Quote
It will even have all the sensors to prevent something getting caught in the jam.
That made me giggle in the context of a kitchen.  Doors have jambs not jams.
1375  Using Arduino / Programming Questions / Re: Not getting I2C address..how to get it.? on: January 28, 2014, 02:02:57 am
Quote
arduino                         gy80
5v                                    3.3v
This does not look like a good idea.  What happens if you connect the gy80 3.3V pin to 3.3V on the Uno, assuming, of course, that it is not too late and that you have not fried the gy80.
1376  Using Arduino / Programming Questions / Re: Servo rotation help on: January 28, 2014, 01:56:50 am
The important thing is to keep the input pins in a known state at all times.  This is usually done by wiring pull up or pull down resistors to the input pins or by setting the pinMode to INPUT_PULLUP which activates the internal pull up resistors.
1377  Using Arduino / Programming Questions / Re: parse string and if statements on: January 27, 2014, 04:20:56 pm
Here is the same principle used to save the output to 2 arrays.
Code:
char inData[] = "c1:255:c2:230:c3:100:c4:205:c5:10";
char* channels[5];
char* values[5];

void setup()
{
  Serial.begin(115200);

  channels[0] = strtok(inData, ":");
  Serial.print(channels[0]);
  Serial.print("\t");
  values[0] = strtok(NULL, ":");
  Serial.println(values[0]);

  for (int i = 1; i < 5; i++)
  {
    channels[i] = strtok(NULL, ":");
    Serial.print(channels[i]);
    Serial.print("\t");
    values[i] = strtok(NULL, ":");
    Serial.println(values[i]);
  }
}

void loop()
{
}
1378  Using Arduino / Project Guidance / Re: software for arduino on: January 27, 2014, 04:05:28 pm
Would it be simpler for you to only answer the questions.
No one asked comments If you don<t know the answer you can only stop posting stupid posts, posts that reflects your stuupidity.
Thank you to be more intelligent!
That's enough for me.  I am out of this thread and will ignore your posts in future.
1379  Using Arduino / Project Guidance / Re: software for arduino on: January 27, 2014, 02:40:03 pm
You need a terminal emulator that interprets graphics commands and displays the results on the screen or you could use Processing.
1380  Using Arduino / Programming Questions / Re: Single step through a program on: January 27, 2014, 02:31:54 pm
These limitations would seem rather awkward to work with
Quote
Pointers not implemented - some sketches with pointers may run but generally pointers don't work
Custom Libraries, structures,classes and enums may or may not work
Other minor issues to do with complicated C++ commands
Pages: 1 ... 90 91 [92] 93 94 ... 274