text:
C: No communication to a connected serial port?
I'm trying to connect to an arduino Mega At2560 unit connected via usb serial port in my linux based PC.
Using C code, I'm trying to send and receive simple text strings, just I'm able to send and receive on both sides.
On arduino:
int incomingByte = 0;    // for incoming serial data

void setup() {
    Serial.begin(19200);    // opens serial port, sets data rate to 9600 bps
}

void loop() {
  // send data only when you receive data:
  if (Serial.available() > 0) {

    // read the incoming byte:
    incomingByte = Serial.read();

    // say what you got:
    Serial.print((char)incomingByte);
  }

}

basically just a loop that checks if there is serial data, and if so reads it and prints it back. there's a (char) conversion so I'll see right away the sent data is what I got back (linux side)
For the linux code I use the pretty standard code for opening a port which I found here
I call the Arduino "Table" as it will eventually operate a moving table through USB commands.
C file:
#include "TableFunctions.h"

bool connected=false;
int fd;
char *portname;

int set_interface_attribs (int fd, int speed, int parity)
{
        connected=false;
        struct termios tty;
        struct termios tty_old;
        memset(&tty, 0, sizeof tty);
        if (tcgetattr (fd, &tty) != 0)
        {
                printf("PC: Error %d from tcgetattr  \n", errno);
                return -1;
        }
        tty_old = tty;

        cfsetospeed (&tty, (speed_t)B19200);
        cfsetispeed (&tty, (speed_t)B19200);

        //tty.c_cflag |= B19200;
        tty.c_cflag     &=  ~PARENB;            // Make 8n1
        tty.c_cflag     &=  ~CSTOPB;
        tty.c_cflag     &=  ~CSIZE;
        tty.c_cflag     |=  CS8;

        tty.c_cflag     &=  ~CRTSCTS;           // no flow control
        tty.c_cc[VMIN]   =  1;                  // read doesn't block
        tty.c_cc[VTIME]  =  5;                  //
        tty.c_cflag     |=  CREAD | CLOCAL;     // turn on READ & ignore ctrl lines
        cfmakeraw(&tty);
        tcflush( fd, TCIFLUSH );

        if (tcsetattr (fd, TCSANOW, &tty) != 0)
        {
                printf("PC: Error %d from tcsetattr  \n", errno);
                return -1;
        }
        return 0;
}

void set_blocking(int fd, int should_block)
{
        struct termios tty;
        memset(&tty, 0, sizeof tty);
        if (tcgetattr (fd, &tty) != 0)
        {
                printf("PC: Error %d from tggetattr  \n", errno);
                return;
        }

        tty.c_cc[VMIN]  = should_block ? 1 : 0;
        tty.c_cc[VTIME] = 10;            // 0.5 seconds read timeout

        if (tcsetattr (fd, TCSANOW, &tty) != 0)
                printf("PC: Error %d setting term attributes  \n", errno);
}

void OpenSerialPort()
{
    char *portname = "/dev/ttyACM0";

    printf("PC: Opening port to table \n");

    int fd = open(portname, O_RDWR | O_NOCTTY | O_SYNC);

    usleep(2000000);
    if (fd < 0)
    {
        printf("PC: Error %d opening %s: %s  \n", errno, portname, strerror(errno));
        return;
    }

    set_interface_attribs(fd, B19200, 0);  // set speed to 19,200 bps, 8n1 (no parity)
    set_blocking(fd, 0);                // set no blocking
    printf("PC: Connected\n");
    connected = true;
}
void PrepareWriteCommand(int numberOfCommands, const char *commands[numberOfCommands])
{
    if(connected) //check if arduino still connected
    {
        for(int i = 0; i<numberOfCommands; i++) //go through commands
        {
            int bufferSize = strlen(commands[i]); //get the buffer size needed for this command
            char charArray[bufferSize]; //helper char array
            memcpy(charArray,commands[i],bufferSize);//copy command to the char array
            charArray[bufferSize]=0; //make sure there is a stop symbok at the end
            WriteSerialPort(charArray); //command is ready to be sent, send it.
        }
    }
}
int WriteSerialPort(const char *buffer)
{
    printf("PC: Now writing: ");
    int n_written = 0; //how many bytes were written

    n_written = write(fd, buffer, strlen(buffer)); //write the command and return how many bytes were written

    printf("\n");

    //check bytes send and return ouput (error, nothing or x bytes sent)
    if(n_written<0)
    {
        printf("PC: Error %d from %s \n",errno, strerror(errno));
    }
    else if(n_written == 0)
    {
        printf("PC: Nothing was written  \n");
    }
    else
    {
        printf("PC: Written %i bytes  \n", n_written);
    }

}

int ReadSerialPort(char *buffer, unsigned int buff_size)
{
    //check if arduino still connected
    if(connected)
    {
        //read the serial data
        if(read(fd,buffer,buff_size))
            return sizeof(buffer); //return how much bytes were read
        else
        {
            //else print nothing received
            printf("PC: Arduino not Connected (ReadSerialPort) \n");
        }
    }
}

in OpenSerialPort I basically open a new fd, and call the functions that set the communication settings.
I use PrepareWriteCommand to make sure commands input from users are with a stop symbol and send them to WriteSerialPort where I use write() and print how many bytes were sent.
H file:
#include <errno.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>

#define MAX_DATA_LENGTH 256

int set_interface_attribs (int fd, int speed, int parity);
void set_blocking(int fd, int should_block);
void OpenSerialPort();
void PrepareWriteCommand(int numberOfCommands, const char *commands[numberOfCommands]);
int WriteSerialPort(const char *buffer);
int ReadSerialPort(char *buffer, unsigned int buff_size);

Main:
#include "TableFunctions.h"
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
    {
        char output[MAX_DATA_LENGTH]; //char array to hold arduino output
        int received = 0; // check if read() got any bytes
        const char* commands[]={"test"}; //test command

        OpenSerialPort(); // open serial port

        PrepareWriteCommand((sizeof(commands)/sizeof(commands[1])),commands); //prepare command for sending

        usleep(500000); //wait for arduino response

        while(true)
        {
            ReadSerialPort(output,MAX_DATA_LENGTH);//check serial port for response
            if(strlen(output)>0) //if anything received
            {
                printf("PC: received %i\n",received); //if yes, how many bytes
                printf("PC: %s\n",output); //and what was received
                usleep(500000);
            }
            else if(strlen(output)<=0) //else print nothing received
            {
                printf("PC: Nothing received\n");
            }
        }
        return 0; //finish program
    }

I tried tweaking the tty flags settings with no success. Each time I run the C code I see the arduino resets (and after opening a new fd I give it some time for bootloading) but no communication is sent between the two.
Output:
PC: Opening port to table
PC: Connected
testPC: Now writing:
PC: Written 4 bytes

PC: received 0
PC:

Any help with understanding why the C code can't communicate with the Arduino will be highly appreciated!

Are you waiting for the bootloader to finish executing before you try sending ... ?

@Majenko yep: int fd = open(portname, O_RDWR | O_NOCTTY | O_SYNC);
usleep(2000000);

was told I never assign received again in ReadSerialPort(), so I fixed it and now I get:
PC: received 8
PC:
I send only 4 bytes so arduino might be sending twice the data in the given time untill PC reads it. It doesn't matter though, right now PC still shows nothing in buffer after I call read()

I might be wrong and the 8 bytes are the size of the pointer (sizeof(buf))

This makes no sense: void PrepareWriteCommand(int numberOfCommands, const char *commands[numberOfCommands])

@Majenko The function gets an array of commands and cycles through it. Basically just preps each command (making sure there's a stop symbol) and sends the to be written through USB one by one.

Yes, but you can't use a parameter to set the size of a parameter. It makes no sense.  You should be using const char **commands or const char *commands[] since you are using an array of pointers.

regarding: Serial.begin(19200);  what about the number of stop bits?  what about the parity?  what about the number of data bits?  Those all need to be set

regarding: ReadSerialPort(output,MAX_DATA_LENGTH);  I doubt that the function: ReadSerialPort() terminates the input with a NUL byte, so any following calls that are expecting a NUL terminated array of characters will not work.  I would expect that function returns a count of the number of characters read, which can be used to insert a NUL byte into the array output[]

regarding: ReadSerialPort(output,MAX_DATA_LENGTH);  The posted code does not check the returned value from ReadSerialPort() AND the actual function: ReadSerialPort() fails to return an error status when (for instance) the port is not connected

regarding: printf("PC: Now writing: ");  this data will stay in the output stream until something happens (like another call to printf() that (properly) has a '\n' as part of the data (perferably the last character output) forces the data to be passed to the terminal

to call to read() will let the code know if anything is there to read.  Waiting some arbitrary time is not a good method.  Much better to keep calling ReadSerialPort() until some data is seen

OT: regarding: printf("PC: Error %d opening %s: %s  \n", errno, portname, strerror(errno));  Error messages should be output to stderr, not stdout.  Suggest: `fprintf( stderr, "PC: Error %d opening %s: %s  \n", errno, portname, strerror(errno));

the functions in the code that handle the IO communications fail to let the caller know when an error occurs, so the caller will (blissfully) keep right on, as though everything is good

Problem was in OpenSerialPort(). I set another variable fd which is local, thus given priority. then when OpenSerialPort() is done, it is deleted, and the global fd remain unset. This is why I can't send anything from or to the PC.
Thanks.


text:
Aurduino Mega prototype board connectors
Might someone shed some light on the 52 pin connectors on the end of the prototype board? Both boards have no 52 pin female connectors, the board that doesn't include the breadboard wire has a male connector that is not 52 pins. The female connectors are hard to find. I've only looked on Ebay.
Thanks
]2

I presume the pictured board has pins underneath (like an Arduino shield). It would be designed so you can stack more than one on top of each other.

Yes, the board is stackable. Not bad for 4.99.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Is there any way to flash sketches using custom firmware?
I am using HIDUINO as my firmware (flashing via dfu-programmer), and to upload sketch I need to re-flash original firmware, upload sketch and then flash HIDUINO again.
Is there a way to flash sketches without reflashing original firmware?

Is the firmware built to start in the bootloader section? Are the appropriate fuses set?

@IgnacioVazquez-Abrams um, I have no idea

I assume you mean you are reprogramming the USB interface chip, which means you no longer have a UART pathway through to the ATMega328P. If so then yes, you can provide your own USB interface in parallel by connecting an FT232 (or similar) breakout board direct to the ATMega328P chip just like you would on a breadboard Arduino:

FTDI TX -> Arduino RX (Yellow)
FTDI RX -> Arduino TX (Blue)
FTDI DTR -> 100nF Capacitor -> Arduino RESET (Green)
FTDI GND -> Arduino GND (Black)

The capacitor is required with later versions of avrdude and newer versions of the Arduino IDE since the DTR signal is now held LOW rather than being pulsed as it used to be.  This is to combat a change in the FTDI drivers that meant that the DTR stopped being driven at all and broke the auto-reset facility.  So now we need a capacitor to convert a constant LOW into a short low-going pulse to initiate a reset without locking it all up.

Or use a second Arduino for this.

Yes, but that's wasteful :)

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
How to read temperature from multiple DS18B20 faster?
I am writing an Arduino sketch to read temp data from multiple DS18B20 sensors and then write it to serial. The problem is, as I am connecting more sensors, the delay between my temp data is written to a serial increases (like 100ms for 1 sensor and 1s for 4 sensors). Can I somehow improve my sketch to read it faster?
Here is the sketch I am using:
(I am using DallasTemperature to simplify it all)
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 10
#define TEMPERATURE_PRECISION 8
#define BAUD_RATE 9600

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress devices[10];
int devicesFound = 0;

void setup(void)
{
  // start serial port
  Serial.begin(BAUD_RATE);
  //Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();

  // locate devices on the bus
  Serial.print("Locating devices...");
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");

  devicesFound = sensors.getDeviceCount();

  // report parasite power requirements
  Serial.print("Parasite power is: ");
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");

  for (int i = 0; i < devicesFound; i++)
    if (!sensors.getAddress(devices[i], i))
      Serial.println("Unable to find address for Device" + i);

  // show the addresses we found on the bus
  for (int i = 0; i < devicesFound; i++)
  {
    Serial.print("Device " + (String)i + " Address: ");
    printAddress(devices[i]);
    Serial.println();
  }

  for (int i = 0; i < devicesFound; i++)
    sensors.setResolution(devices[i], TEMPERATURE_PRECISION);
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    // zero pad the address if necessary
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

// function to print the temperature for a device
String printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC < 10)
    return "0" + (String)tempC;
  else
    return (String)tempC;
}

// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
  Serial.print("Resolution: ");
  Serial.print(sensors.getResolution(deviceAddress));
  Serial.println();
}

// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
  Serial.print("Device Address: ");
  printAddress(deviceAddress);
  Serial.print(" ");
  printTemperature(deviceAddress);
  Serial.println();
}

void loop(void)
{
  if (devicesFound == 0)
  {
     Serial.println("No devices found.");
     return;
  }

  sensors.requestTemperatures();

  String sent = "";

  // print the device information
  for (int i = 0; i < devicesFound; i++)
  {
    sent += printTemperature(devices[i]);
    if (i != devicesFound - 1)
      sent += " ";
  }

  Serial.println(sent);
}

A trivial change, but I think it's cleaner:  Where you are adding spacing to the string, I'd use if (i) sent += " ";  as a statement before the statement adding the reading to the string, instead of the statement you currently have after

I would start by changing this section:
String sent = "";

// print the device information
for (int i = 0; i < devicesFound; i++)
{
  sent += printTemperature(devices[i]);
  if (i != devicesFound - 1)
  sent += " ";
}

Serial.println(sent);

This section should read and print the temperature directly instead of creating a string. The string handling is a large overhead and it does not allow Serial (UART) to work very much in parallel if the buffer is filled. The printTemperature() function is using a lot of strings (and heap operations).
Otherwise you have done what is possible; 1) reduce the conversion resolution (9-bits is minimum), 2) use single conversion request command to all sensors.
The alternative is to use alarm triggers and only read sensors with alarms.

like that http://pastebin.com/NubeaW4M ?

What are the results of that? I did some tests and it is possible to issue a conversion request, read and print the results from 48 sensors at 9-bits resolution and 14 sensors at 12-bits resolution (per second).

delay is still the same

Can you scale it down to a single sensor and measure the conversion request and reading of scratch pad? We need to isolate the issue in the library that you are using.

So, I changed my sketch this way: http://pastebin.com/7EADdVAu, and it shows that around 110ms has passed while reading one sensor.

For 5 sensors it now shows values around 163ms, that's strage, it was bigger when I ran it earlier.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Cannot control servos through 32-servo-controller on Aurduino Duamilanove
I have servo (TowerPro sg90) connected to 32 servo controller (this one) through UART interface (RX-TX, GND-GND).
Seller provide documentation how to connect and control my servos, but it isn't work.
Servo work if I connect it indirectly to Arduino. Controller indicate that it is working too (photo below - red led).
I already try different servos. Also try use provided software to control servos from pc through Mac/PC. But it's interface is unreadable for me. I tried different options but servos not responding.
Sketch code below (from sellers examples):
void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.print("#3P500T2000\r\n");
  delay(2000);
  Serial.print("#3P1500T2000\r\n");
  delay(3000);
  Serial.print("#3P2500T2000\r\n");
  delay(2000);
  Serial.print("#3P1500T2000\r\n");
  delay(2000);
}

Photo of my connections:

Sorry if it post duplicate some, but I cannot google this problem.

Just as additional information. If there is a PS2 controller attached to the board, then the serial port seems turned off.

There is one connection missing - the one that powers the servo and board.
At the moment your servo board is getting a small amount of power through the RX pin - disconnect it immediately, you are damaging it.
You need to provide +5V to the +5V terminal block, and also a suitable voltage (+5V should do) to the VCC on the terminal block.

Thank you very much. I will try and accept your answer as soon as possible. Can you provide some reference where I can read about it? Because I cannot figure it out by provided docs.

@rkyr The reference is simply that the servo and board need power (all servos and boards need power) yet you have not provided any. No docs are needed for that - it's just basic knowledge.


text:
How many LED Strips can we connect to an Arduino Uno? Is there a way to connect 1-3 meters worth without needing extra parts (relays)?
I am looking at Adafruit to purchase some LED strips for a mod for my computer case, and want to power it with an Arduino.
I am looking at the Uno, but the Mega looks good too.  I hear the Uno is good because if the chip fries, you can just replace it easier than the Mega's chip.  I did hear that the Uno chip had issues, but that was a 2013 post.
Anyways, I am essentially looking to connect about a foot of 144 leds/m to the front of my case, and connect that to the Arduino.  I will then be lining the inside of my case with about 12-15" per side (x4 sides) of 60 leds/m so I wanted to connect that to another part of the Arduino.
I read that each led takes something like 6mA or 60mA each, so that is what we should watch for.  I was trying to search for this question that others asked, but people were looking to connect a lot of strips, and needed relays and whatnot, so I wanted to make sure the Arduino itself could power about 1.5 to 2 meters of Led strips in at least 2 different strip configs (or whatever you want to call them).
I also am curious if there will be an issue programming each strip setup or, if it just is a little more work to get it setup?
Since this is a computer cause led setup, I'm not sure if I should go USB power, or a wall charger?  What is the recommended approach for something like this?
I will definitely be reading up more tutorials and all that important stuff, but I want to buy the stuff now since I realized there's a cyber Monday deal going on, so I don't want to miss out...
Any help is appreciated, thank you!

Yes, the current draw is the main factor here.  That's not really an Arduino issue though, as I will enlighten you about later on when I talk power supplies.
I assume, since you don't mention what the LEDs are, that you are talking about strips of WS2812 "NeoPixel" LEDs (the ones where you can control the colour of each and every individual LED).
I would recommend keeping all the LEDs as one single strip.  That doesn't mean you can cut the strip into segments, just join the ends to each other using wire in one chain.  That way you just have one chain to deal with in the Arduino.  Running multiple chains can be somewhat more resource hungry and I'm not even sure it's possible on an Arduino.  So keep it all as one long chain split into chunks and re-joined with wire.
Now for power.  Your computer has a big powerful power supply in it.  That gives a very good regulated 5V supply with many many amps available.  More than enough to run hundreds of LEDs.  By all means run the Arduino from USB (makes for easy programming - inspect your motherboard, it may well have an internal USB connector that would be ideal (I know mine has).  And then run the LEDs themselves off the +5V direct from the computer's power supply.  A spare hard drive power connector could be good for that.

Thanks for the information.
I'm not sure if there are different kinds, but I'm looking at these
https://www.adafruit.com/products/2328
I'm not sure if the Dotstars are needed over the Neopixels, but they aren't that much more expensive I guess....
So multiple chains aren't a good idea for this? Is there anything that can run them?
I'm just not sure if a I can connect 144 and 60 led strips together?  Also where would I add in the second power connection since ti seems after a meter things start to get dimmer?
For the psu I pull off one of the 5v+ plugs from lets say the 6 pin molex/sata

and then connect it up somewhere on the Arduino (will find out obviously).  I was hoping I could connect it directly to the MB, so that's good.
So I run the Arduino off of the usb, but I run the LEDs from a 5V+ rail?  I figured I ran the LEDs right from the Arduino?
I also read that I could connect multiple Arduinos together with something like the wifi or another shield?  Would that be a smarter approach, but Idk if I need to spend another 25$...?
Thoughts?
Thanks!

They look similar to the WS2812 but I think they are "lighter" on the MCU, so you should be able to have multiple chains. Connect the +5V direct to the LEDs +5V, the LED's ground to both the Arduino ground and the PSU ground, and the LED's data line(s) to the Arduino. Power the Arduino from USB.

Hmm so you think the dotstars will be good then ?  So I would need some sort of wire splitter or something or how do I connect all of this jazz to the Arduino?  I'm not sure what "necessary items" I need to buy....
How can I figure out if I 100% can use multiple chains or not?  I'm not sure if there is anything on ADafruit's site, or if I should check the forums or what not...
Thoughts?
Thanks!

Dotstars look good, yes. You don't need any fancy wire splitters, just some wire cutters and electrical tape will do the job. A soldering iron is probably needed too. I haven't used the Dotstars so I can't say for sure if you can do multiple chains or not - best look at the manual, libraries, examples, and see if anyone else on here has first hand experience of working with them. I'm sure someone else can chime in.

Hmm thanks.  So I just need to split the wire and it will work?  How many times can you split a wire?  Just as long as there is some mini strand that can connect from one source to another to create a current?  sorry if this is a basic electronics question.
I do have a soldering iron and electronics tape, but I figured I would resort to getting down and dirty only if need be.
I don't need multiple chains, as long as I can power the strips enough.  I realize that the strips are powered from an external source, so I guess it will work how I want it.  But a 144 led strip with a 60 led strip?

Oh and will this work for the ground connections?
https://www.adafruit.com/products/1494
these are "Splices" there is one that is a 2 in and that's it, but this 2 in, one out, seems better. I guess the 2 in is just a connection to the 2 wires, but above seems useful for ground connection.  Maybe I'll grab a few of these?
Thoughts?  Thanks!

The important thing to understand here is that there are two things going on:

Powering the LEDs – that's the big power draw and it makes a ton of sense to do that off of the computer power supply.
Controlling the LEDs – that'a a very small load, using one (NeoPixel et al.) or two (DotStar et al.) pins on the Arduino. So there is no need to do anything fancy, you should have more than enough drive in the Arduino pin(s) to handle the LED control.

You might want to take a look at the FastLED library (or head directly to the GitHub repo) it explicitly support multiple strands of LEDs (and interchangeably supports a whole slew of LED type including NeoPixels and DotStars. I think, but haven't tried, you could support multiple strands of NeoPixels by creating several instances and giving each instance its own pin.
DotStars come (if you get a "finished" end) with a connector that has all four wires (Vcc, Gnd, data, and clock) as well as two additional wires for "bulk" power. But if you don't get a finished end you would just solder to the pads that are at each cut point. You probably want to power the strip(s) in parallel – feeding them from each end so that the LEDs at the end don't see too much of a voltage drop.

Thanks for the tips, much appreciated.  I was confused thinking the power was directly from the Arduino.  I've seen peopel use the PSU itself, so I guess I just rip out one of the 5V+ and a ground from the LEDs to the Arduino and PSU?
The issue I'm having is I'm going to be using some 144 LEDs/m and some 60 LEDs/m, so I'm not sure if they are compatible, or what...?
Thoughts/
Thanks! :)

Yes, that's right – either use a spare disk drive connector or put in a wye connector to tap one. I'd be surprised if you didn't have spare. The 144 LED/m and the 60 (and 30) LED/m tapes are all compatible. For the strips that you want to run the same "program" chain their data lines together. If you want to control a strand separately, give it its own data line (on the DotStars I'm not sure if you can use a common clock with individual data lines for segments with different programs, but it seems like that might be possible.

I have a few 4 pin molex connectors from my previous build, but I noticed the pSU I'm looking at has a 6 pin molex/Sata, so I'm not sure what that's about compared to the 4 pin...
There is the 4 pin connector thing on Adafruit's site, but it's out of stock for now :(.  Would it be better to get one of those or...?
I feel like I have a lot to read up on!
I'm also hoping to turn on the Arduino when my comptuer turns on.  Not sure how difficult that is.  I'm looking at one of the Keypads, so it would be interesting to turn it on with a keycode :)!

The wires should be color coded, one of the easier things to do would be to cut off the Molex connector and go directly to the strip (or just pick a connector that you can easily get (like spade or bullet quick connects). If you power the Arduino via USB from the computer it will power up with the computer.

Yeah, I believe red is 5V+?  I'm not sure I follow what you mean by "cutting off the molex connector" do you mean just taking out the red wire or..?
I'll look up the quick connects though.
I could power the Arduino from the wall and then have the computer be turned on from the Arduino right?
Thanks!

I just meant that you don't have to use the Molex if it is hard to find a matching connector, you could pull the wire out or just cut off the connector and treat it as a bare wire. I'd be tempted to handle power the other way around. Power the Arduino from a USB port on the computer (or from the power supply) otherwise you'll need to figure out how to control the power supply and how to integrate that into the Arduino system.

I guess I'll have to see howi t works when I check out some tutorials, it's hard to envision now, but I'll get it.
Well, I see the power can be powered by a wall charger, so I figured if I powered the Arduino with that, and then could power the computer from the ARduino, I would like that :).
Also, I wanted to know if a breadboard is needed to run all of this stuff, or if we had additional things?  Not sure if there is a way around it.
Also I think we need these breadboard wires, right? https://www.adafruit.com/categories/306
I'm assuming I only need male/male?
Thoughts?  Thanks alot! :)

The other answers you have here cover the points well, just to offer my $0.02.
Using a wall adapter
It's really not necessary to use a separate wall adapter and you'd be adding another layer of complexity unnecessarily. So don't bother. Also with a wall adapter you would have to consider grounding it to the computer's power supply, not necessarily an issue, but not required if you use internal power.
Powering your LEDs
your computers power supply is more than capable of handling EVERYTHING you've mentioned (unless you're already maxing it out, which I doubt).
Just make sure that you're powering the LEDs directly from the computer's power supply, and not from the (arduino) board itself, since that 5v is limited to 500mA from the USB connector, and definitely don't drive the main power from a data pin (I'm sure you know that—but just in case :P)
If you do split the strip (running two strips shouldn't be a problem) be sure to provide power where ever you can, ie each end, even in the middle. It will aid in providing even power throughout the strip.
Powering the Arduino
I'd be running the Arduino off it as well, either grab a header cable off the board that has an end you could plug into your arduino and mount it inside, or feed a USB cable through the back and use one of the extra external USB ports. A bonus of running it outside would be you could physically reset the board by unplugging it :) or simply turning it off by doing the same.


text:
Looking at Adafruit's website I'm confused which wallcharger I should get
As the title says there are many different wall chargers to choose from.
12v, 9v, 5v, with different mA amounts...
The starter kit on Adafruit's website mentions to get the 9V 1000mA switching power adapter, so I'm curious if that's what we should get?
here is the link to all of them.
There are regular wall adapters, and these big power supplies...
http://www.adafruit.com/search?q=switching+power+adapter&b=1
I'm just looking to run some LED Strip lights from the arduino and power some joystick buttons, some rotary encoder/knobs, and a keypad to work the LED lights
Thoughts?
Thanks!

This website looks like a pretty official answer for you.
http://playground.arduino.cc/Learning/WhatAdapter

Since you'll probably be connecting other things to the Arduino (LEDs, LCDs, servos) you should get an adapter that can supply at least 500mA, or even 1000 mA (1 ampère). That way you can be sure you have enough juice to make each component of the circuit function reliably.

And

The Arduino's on-board regulator can actually handle up to 20V or more, so you can actually use an adapter that puts out 20V DC. The reasons you don't want to do that are twofold: you'll lose most of that voltage in heat, which is terribly inefficient. Secondly, the nice 9V pin on the Arduino board will actually be putting out 20V or so, which could lead to potential disaster when you connect something expensive to what you thought was the 9V pin. Our advice is to stick with the 9V or 12V DC adapter.

Thank you very much :).
I guess I also could just plug it directly into this computer via USB?  I was thinkign that my new build would be done afterwards, but forgot about this comptuer :P
Thanks!

Your Arduino Uno will use 35 to 50 mA at 5V.  The  “joystick buttons, some rotary encoder/knobs, and a keypad” will draw a small amount of current, probably between 1 and 10 mA.  Thus, power for the Uno and your controls will be well under 100 mA and can be supplied via USB without any problem.  (Also see: How to get more than 100mA from a USB port.)
If your Uno enumerates and negotiates to get 500 mA via USB, you might have 450 mA available out of the +5V pin.  However, in some cases if you need more than a few dozen mA to power other devices, it will make sense to get a separate 5V supply for them.  (Eg, if the devices drag down the +5V and cause the Uno to reset, or if the devices are electrically noisy, like motors, RC servos, relays, solenoids.)  Also, note that thread #70450 at forum.arduino.cc says you can draw 650 mA (or 3.25 W of power) when the Uno is powered via its DC power jack.
If your LED string has up to 6 or 7 WS2812B equivalents, you can power it from the Uno's 5V.  Here is the all-lights-on, full-brightness calculation for six of them:  6 WS2812Bs x 3 LEDs per WS8211 x 21 mA per LED = 378 mA.  For seven:  7 x 3 x 21 mA = 441 mA, which is out there on the edge.
For longer LED strings, figure on a little over 3 W of power for every 10 WS2812B equivalents.  (Calculation: 5 volts x 10  WS2812Bs x 3 LEDs per WS2812B x 21 max mA per LED = 3150 mW = 3.15 W.)  For example, get a 10 W (2 A x 5 V) or greater 5V power supply for a meter of 30- WS2812B-per-meter LED strip, etc.  This power supply will connect directly to the LED strip's power connectors.  The ground from the LED strip will connect to the Uno's ground, to establish a signal reference point.
Note, the absolute max voltage rating for a WS2812B, according to its datasheet, is 5.3 V, so use a supply whose voltage does not exceed 5.3 V.  The absolute min voltage rating is 3.5 V; they will work ok on 3.7 V LIPO batteries, but 3V3 power is out of spec for a WS2812B.
As mentioned in a previous question, if your LED strip is being installed inside a desktop PC, the PC's power supply will have lots of 5 V power available, and you can hook on to one of the red +5V wires and black Gnd wires from its supply to power the LEDs, either while powering the Uno itself from USB power or while using the same +5V to power the Uno as the LEDs.


text:
When is it necessary to use "float" instead of "int"?
I'm very new to Arduino and I am making a code for a pedometer.  I have a lot of variables and I have used "int" multiple times, but I just came across a code with "float".
Now because my coding background is next to none, I don't really understand the concept of a float and when it's appropriate to use one.
Could someone please give me an explanation.
Thanks!

use them for intermediate division in places map() won't work

An integer is a whole or natural number.  Computers use integers for counting and comparisons.  Computers can count precisely using integers and comparisons of two integers can be absolutely true or false.
To make a float or floating-point number, a computer uses two integer numbers.  It uses one integer as the mantissa and the other as the exponent.  Computers use floats for calculations involving very large, very small or fractional values.  In other words the set of real numbers.  Computers can not count very well using floats.  Computer can not even compare two floats very well. That is to say, you may get different results from different computers when testing if two different floats are the same or not. This is due to rounding error.
Consider that the set of real numbers between 0 and 1 to be infinite.  However, intuitively, we know computers can not keep track of an infinite number of unique values between 0 and 1.  After all, computers use a float to do this and a float has a finite number of bits in it's mantissa and exponent.  The difference, if any, between the actual real number from, say, a calculation and the next possible float value is commonly referred to as the roundoff error.  In a program, a difference, for example, in the order of operation is enough to cause different roundoff errors to occur resulting in two slightly different float value results.
Rounding errors are what we end up with for allowing float values to grow very large or very small or to contain factional amounts.  Fortunately, floats are exactly what we need when computers are asked to calculate very large, very small or fractional numbers.
In embedded programming we rarely use floats.  They take up more of our limited RAM space than integers.  And it is rare that we need to calculate very large or very small numbers.  Usually, in embedded programming, we are counting events or measuring sensors.  Usually integers are preferred or are sufficient for our purposes.
Addressing your specific application (pedometer):
It is anticipated you would prefer to track distances in miles.  And it is practical to assume a good pedometer displays factional miles.  You can use floats to calculate this value.  A rigorous programmer would cast their integers as floats when mixing them in equations to make it clear to the compiler what is desired.

Computer can not even compare two floats very well. This is very wrong. Computers can easily compare two floats. You just have to know exactly why (on a particular CPU) float x=1.1; bool ok=x==1.1; results in not ok. Mandatory reference is What Every Computer Scientist Should Know About Floating-Point Arithmetic.

I appreciate the rigorousness of your comment.  I will reword my answer.

@st2000: You wrote: “[floats] always have a certain amount of imprecision”. This is incorrect, floats are exact numbers. Only the operations done on them may incur rounding error. @Ruslan: You wrote: “float x=1.1; bool ok=x==1.1; results in not ok”. On most Arduinos (the AVR-based ones) it results in ok.

@EdgarBonet OK, I was right to note "particular CPU". Your comment is quite interesting though. AFAIR, AVRs don't have FPU, so float should be "emulated" in software. Based on your comment though, it seems that this emulation makes float and double identical. What is your compiler?

@Ruslan: It's gcc, which is the standard for Arduino. You are absolutely right. AVR floats are implemented in soft, and double is implemented the same as float.

Hi @EdgarBonet, I see your point.  I will attempt to reword the answer.  I appreciate the comment.  This is stackexchange and normally answers are much shorter than "white papers" and usually shorter than wikipedia entries.  I am trying to stay in that format yet provide enough detail for informed decisions.  Let me know if you have any further concerns.

For a pedometer program I would expect number of steps to be an int. I would then have step size in cm or mm also as an int. Internal calculations of distance would then be made purely using ints (or long ints if you need numbers larger than an int can handle). Only when calculating the value to display would you convert to a float and scale into miles or km as needed. That way rounding errors never accumulate, all the internal calculations are exact because they use ints.

"int" means integer. It's either one whole number (forgive me, mathematicians, for the sloppy definition!) or the next or previous.
A "float" is a floating-point number - that is, a number and part of a number.
3 is an int
3.14 is a float
If you need to store/represent a value that can be between integers, you could use a float.
Floats use more RAM than integers, and there is a limit to the precision they can represent. Don't use a float unless you have a need.

"Floats use more RAM than integers" This isn't necessarily always true, some floats are 32 bit and many integers are 32 or even 64 bits.

When is it necessary to use “float” instead of “int”?

IMHO in Arduino world it is never necessary to use float ; well unless you want to do something very fancy like building a space ship route calculation with Arduino. In which case you will have someone on your team who understands the problem in full detail who can decide it is better to use float for some calculations.

How do I deal with behind the comma numbers?

As integers does not allow you to work behind the coma and you won't use float you may wonder how to work with pi (3.1415..radians). In most cases you will only work with a specific number of digits behind the comma. Lets say you want 3 digits behind the comma. In this case you simply work with milli radians instead of radians ( 3145 milli radians=3.145 radians; For the Americans it might be time to look at the metric system for a better understanding)
Because of this change in "base value", no more floats are needed to calculate.  There are 3 drawbacks:

when out-putting information formatting may be needed/desired to
convert to a user "base value".
when in-putting information formatting may be needed/desired to
convert to a user "base value".
When using methods that use float conversions are needed
In and output are normally very small in arduino. The Serial.print() is probably the biggest thing.
If you need to use a method like cos() you do as follows:
long result=DECIMALDIGITS*cos((float)corner/DECIMALDIGITS);
Where DECIMALDIGITS= (float)10^numdigits;

As type I advice to use long on a 8 bitter as int (-32,768 to 32,767) is very likely to get out of range.
More background behind the dirty details of float
It is pretty obvious that float supports behind the comma values, but what are the disadvantage of float?

float is CPU/RAM intensive
float introduces a rounding problem.
multiple types int/float can cause casting issues

Lets go through the disadvantages one by one:
float is CPU/RAM intensive
IMHO In many Arduino projects there is plenty of CPU/RAM left so I don't think this is a real issue.
To prove this point look at how many Arduino projects contain a delay(x00) in the loop; so if things go to slow simply decrease this number to release some CPU cycles ;-).
float introduces a rounding problem.
*When using floats A * B / A does not guarantee to be equal to B!!!* It will be close but ...
This is my main argument to avoid floats. Sooner or later this will hit you and you'll have a hard time finding out why. (I speak from experience here)
Basically 0.1 can not be represented 100% exactly in float. So in float 0.1+0.2 is not equal to 0.3!!!
multiple types int/float can cause casting issues
In C/C++ it is pretty hard to predict the casting that will happen in a formula like:
float z;
byte r;
uint32 t;
...
int a=z*r/t*1.5;

I consider myself very experienced in C/C++ and I always convert code like this into something like
float z;
byte r;
uint32 t;
...
byte rfloat=r;
uint32 tfloat=t;
int a=(int)(z*rfloat/tfloat*1.5);

I prefer not to explain this to a newbie Arduino user :-s.
More in depth details can be found at floating-point-gui.de

While in principle I agree with you, it should be noted that the alternative, namely fixed point arithmetic, is hard, especially for the novice: you have to figure out the proper scaling to apply to your numbers at every step of every calculation. With floats, in contrast, the optimum scaling is automatically computed at run time.

In Arduino world I would disagree. The answer is: Take long. int goest to +-32.700 so is probably to small for cents and for sure to small for millis.
Long still has a huge cpu and memory gain compared to float.

And do not forget. In Arduino world the biggest input is 1023 from the analog read. I challenge you to give a example where long is not long enough for a "normal" arduino project. So no space travelling

No, long is not the universal answer. Sometimes the cost of writing a fixed-point code is just not worth the trouble if you have enough time to do it with floats. You could certainly compute a cos() using only integers (I did it), but you cannot expect a novice to do that.

I do not advice to write your own cos only using integere. I'll mod the answer.

I edited the answer.

I'm very new to Arduino and I am making a code for a pedometer.

others have answered the difference between float and int.
but your project offers an interesting challenge in that it covers a wide range: the pedometer likely counts in miles and have to keep track of total steps, which the increments are done in single steps - much shorter than miles.
what you could do instead of using floats is to use multi-byte types. for example, a 32-bit/4-byte type can support 2 million miles; you can add additional msb to it to create a proprietary data type. a 5-byte type for example would support 5 million miles, and a 128 billion miles for a 6-byte type.
you will need to create your own math routines -> not difficult at all.
the point is that float is a simple solution to simple problems only.

There are tons of scientific computations done with floats. And no, not only simple problems.

There are much more details on both data types, but to keep it easy, just a rough explanation:
integer data types only allow a range from -2,147,483,648 to 2,147,483,647 with 4 Bytes of memory per variable.
If your results exceed that numbers, an over- or underflow will occur. If you don't take care, bad things can happen.
And you can only use whole numbers, there is no decimal point.
float instead allows you to do your calculations directly typing decimal values (like 1.25, 3.14, ...), just like you do on paper.
Plus: You usually don't have to care for range checks, because that data type covers a huge value range (-3.4028235E+38 to 3.4028235E+38 with also only 4 Bytes of memory per variable!
So why not use float by default?
One big drawback is that handling this number format requires a special piece of hardware ("Floating Point Unit", FPU) to be efficient.
If your microcontroller doesn't have an FPU (and the small Arduinos don't have one), every calculation using float operands requires to call certain functions which use some rules to convert your float operands into integer data types, do the calculation on integer basis and convert the result back to float.
This consumes some memory and a lot of CPU cycles, which can slow down calculation speed to about 1/10 compared to using an FPU.
There are some other issues which make working with float a little bit tricky, so if your calculation can be done using integer, use this instead.

"And what if i need decimal numbers?"
You can't type 3.14 in integer, but you can multiply it to a value big enough to consider enough decimal places for your application. You just have to define the factor and  imagine the decimal point.
For instance, multiply your values by 1000, then 3.14 * 1.256 = 3.94384 becomes 3140 * 1256 = 3943840 internally.

int stands for Integer
and float stands for floating point number.
For more reference check this out https://www.arduino.cc/reference/en/language/variables/data-types/float/


text:
Can't communicate my 2 Xbee modules using API mode
I want to create a network with 10 routers/end devices and one coordinator with my Xbee Pro S2C devices. For That I know I have to do it in API mode. I configured one as a coordinator (DH=0, DL=FFFF, CE=1, AP=1) and one as a router (DH=0, DL=0, CE=0, AP=1) and then I tried making them communicate with the xbee-library for Arduino.
I used this for the coordinator:
XBee xbee = XBee();
uint8_t *payload= "Hello!";

//XBeeAddress64 CoordinatorAddr64 = XBeeAddress64(0x0013A200, uint8_t *payload= "Hello!";0x40C8CA96); //Put the address of the node explicitly.
//XBeeAddress64 CoordinatorAddr64 = XBeeAddress64(0x0013A200, 0x4125f767); //The address DH:DL = 0 for coordinator always
XBeeAddress64 CoordinatorAddr64 = XBeeAddress64(0, 0); //The address DH:DL = 0 for coordinator always
XBeeResponse response = XBeeResponse();
ZBRxResponse rx = ZBRxResponse();
ZBTxRequest zbTx = ZBTxRequest(CoordinatorAddr64, payload, 7);
ZBTxStatusResponse txStatus = ZBTxStatusResponse();
ModemStatusResponse msr = ModemStatusResponse();

void setup()
{
  Serial.begin(9600);
  Serial1.begin(9600);
  xbee.setSerial(Serial1);

  Serial.println(("ZB Node-" + String(NODE_TYPE)+ " FW Version:"+ String(NODE_VERSION)));
  Serial.println(("Arduino Setup Finished on " + String(NODE_NAME) + ". Console should show up!"));
  Serial.println("------------------------------------------------------------------------------");
}

void loop()
{
  // put your main code here, to run repeatedly
  String sample;          //Our incoming messages from coordinator will be collected in this variable.
  uint16_t senderShortAddress;

  xbee.send(zbTx);

  delay(5000);
}

And for my router, I'm simply trying to receive the data and I'll send data to the coordinator when I am able to read data.
XBee xbee = XBee();

uint8_t *payload= "Hi!";

//XBeeAddress64 CoordinatorAddr64 = XBeeAddress64(0x0013A200, 0x40C8CA96); //Put the address of the node explicitly.
XBeeAddress64 CoordinatorAddr64 = XBeeAddress64(0x0013A200, 0x4125f755); //The address DH:DL = 0 for coordinator always
XBeeResponse response = XBeeResponse();
ZBRxResponse rx = ZBRxResponse();
ZBTxRequest zbTx = ZBTxRequest(CoordinatorAddr64, payload, 4);
ZBTxStatusResponse txStatus = ZBTxStatusResponse();
ModemStatusResponse msr = ModemStatusResponse();

void setup()
{
  // put your setup code here, to run once:
  pinMode(STATUS_LED, OUTPUT);
  pinMode(ALIVE_LED, OUTPUT);

   //initialize timer-1 (16 bit timer) for normal timer overflow mode
  Timer1.initialize(500000); //defined in value/1000000 toggleStateFn called every 500 milliseconds.
  Timer1.attachInterrupt(toggleStateFn);

  Serial.begin(9600);
  Serial1.begin(9600);
  xbee.setSerial(Serial);

  Serial.println(("ZB Node-" + String(NODE_TYPE)+ " FW Version:"+ String(NODE_VERSION)));
  delay(3000);
  Serial.println(("Arduino Setup Finished on " + String(NODE_NAME) + ". Console should show up!"));
  Serial.println("------------------------------------------------------------------------------");
}

void loop()
{
  uint16_t senderShortAddress;
  xbee.readPacket();

  if(xbee.getResponse().isAvailable()){
    Serial.print("Available ");
    Serial.println(xbee.getResponse().isAvailable());
    Serial.print("Api ID: ");
    Serial.println(xbee.getResponse().getApiId());

    XBeeAddress64 senderLongAddress = rx.getRemoteAddress64();
    senderLongAddress = rx.getRemoteAddress64();
    Serial.print(senderLongAddress.getMsb(),HEX);
    Serial.println(senderLongAddress.getLsb(),HEX);

    //Get the 16bit address of source node from incoming packet.
    Serial.print("Source Node short address:0x");
    senderShortAddress = rx.getRemoteAddress16();
    Serial.println(senderShortAddress,HEX);
  }
}

When I run the code I get nothing on the router.

I checked my connections (OK, Tx1 for MEGA connected to DIN, pin3, and Rx1 connected to DOUT, pin 2);
I verified that the signal is getting to the Xbee
Verified the packet. Connected it to serial 1 and just printed it to the serial console and I see that the packet goes correctly to the Xbee (7E 00 15 10 01 00 7D 33 A2 00 41 25 F7 67 FF FE 00 00 48 65 6C 6C 6F 21 00 63) and I can see that the same packet is going in the signal
When I first got the modules I just started printing from one side to the other and it worked. It was in transparent mode and not in API mode.

The thing is that I can't even get one coordinator and one router to communicate and I want to create a coordinator-10router network. Which means I'm in trouble. Could there be something wrong in my configuration? Is there something wrong in my code? Perhaps I'm using the wrong XbeeAddress64? Is it a problem with the library I'm using?

I'm struggling with XBEE communication myself, but should xbee.setSerial(Serial) be xbee.setSerial(Serial1)?

The library didn't work so i built my own much simpler library. It started working just by coincidence. The problem was in my physical connections to the xbee module. The signals were either not getting to the module or to the arduino (I wasn't using a shield, I simply solderedwires to the pins and then to a protoboard and I found out that the protoboard was faulty)


text:
I want to obtain the output of GPS at every 5 secs and store them onto database using Arduino uno,GPS SKG 13BL and GSM module??
I am on a project,in which I need to store the output of GPS from SKG 13BL to a database using Arduino UNO and GSM module.I wrote the following code
#include <SoftwareSerial.h>
#include <AltSoftSerial.h>
#include <NMEAGPS.h>

SoftwareSerial GSM(2, 3); // RX, TX: Connect TXD to RX & RXD to TX

static const int RXPin = 8, TXPin = 9;
AltSoftSerial gpsPort(RXPin, TXPin);
static const uint32_t GPSBaud = 9600;

NMEAGPS gps;
gps_fix fix;
uint8_t fixCount = 0;
char dt[15],tm[15];

enum _parseState {
  PS_DETECT_MSG_TYPE,

  PS_IGNORING_COMMAND_ECHO,

  PS_HTTPACTION_TYPE,
  PS_HTTPACTION_RESULT,
  PS_HTTPACTION_LENGTH,

  PS_HTTPREAD_LENGTH,
  PS_HTTPREAD_CONTENT
};

enum _actionState {
  AS_IDLE,
  AS_WAITING_FOR_RESPONSE
};

byte actionState = AS_IDLE;
unsigned long lastActionTime = 0;

byte parseState = PS_DETECT_MSG_TYPE;
char buffer[80],url[80];
byte pos = 0;

int contentLength = 0;

void resetBuffer() {
  memset(buffer, 0, sizeof(buffer));
  pos = 0;
}

void sendGSM(const char* msg, int waitMs = 500) {
  GSM.println(msg);
  while(GSM.available()) {
    parseATText(GSM.read());
  }
  delay(waitMs);
}

void setup()
{
  GSM.begin(9600);
  Serial.begin(9600);
  gpsPort.begin(GPSBaud);

  Serial.println(F("GPS LOADING....."));
  Serial.println(F("Testing by : "));
  Serial.println(F("Billa"));
  Serial.println();

  sendGSM("AT+SAPBR=3,1,\"APN\",\"vodafone\"");
  sendGSM("AT+SAPBR=1,1",3000);
  sendGSM("AT+HTTPINIT");
  sendGSM("AT+HTTPPARA=\"CID\",1");
}

void loop()
{
  unsigned long now = millis();

  while (gps.available( gpsPort )) {
    fix = gps.read();

    // Once every 5 seconds...
    if (++fixCount >= 5) {
      displayInfo();
      fixCount = 0;
    }
  }

  if ((gps.statistics.chars < 10) && (millis() > 5000)) {
     Serial.println( F("No GPS detected: check wiring.") );
     while(true);
     block=1;
    }
  }

  if ( actionState == AS_IDLE ) {
    if ( now > lastActionTime + 5000 ) {
      sprintf(url, "AT+HTTPPARA=\"URL\",\"http://*****.000webhostapp.com/hinderset.php?date=%s\"", dt); // passing date only now as part of testing
      sendGSM(url);
      sendGSM("AT+HTTPACTION=0");
      lastActionTime = now;
      actionState = AS_WAITING_FOR_RESPONSE;
    }
  }

  while(GSM.available()) {
    lastActionTime = now;
    parseATText(GSM.read());
  }
}

void displayInfo()
{
  Serial.print(F("Location: "));
  if (fix.valid.location) {
    Serial.print( fix.latitude(), 5 );
    Serial.print( ',' );
    Serial.print( fix.longitude(), 5 );
  } else {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Speed: "));
  if (fix.valid.speed) {
    Serial.print(fix.speed_kph());
    Serial.print(F(" KMPH "));
  } else {
    Serial.print(F("INVALID"));
  }

  // Shift the date/time to local time
  NeoGPS::clock_t localSeconds;
  NeoGPS::time_t  localTime;
  if (fix.valid.date && fix.valid.time) {
    using namespace NeoGPS; // save a little typing below...

    localSeconds = (clock_t) fix.dateTime; // convert structure to a second count
    localSeconds += 5 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE; // shift timezone
    localTime = localSeconds;              // convert back to a structure
  }

  Serial.print(F("  Date : "));
  if (fix.valid.date) {
    sprintf(dt,"%02d/%02d/20%d",fix.dateTime.date,fix.dateTime.month,fix.dateTime.year);
    Serial.print(dt);
  } else {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Time : "));
  if (fix.valid.time) {
    if (localTime.hours>12)localTime.hours-=12;//To convert 24 hr format to 12 hr format
    sprintf(tm,"%02d:%02d:%02d",localTime.hours,localTime.minutes,localTime.seconds);
    Serial.print(tm);
  } else {
    Serial.print(F("INVALID"));
  }

  Serial.println();
}

void parseATText(byte b) {

  buffer[pos++] = b;

  if ( pos >= sizeof(buffer) )
    resetBuffer(); // just to be safe

  /*
   // Detailed debugging
   Serial.println();
   Serial.print("state = ");
   Serial.println(state);
   Serial.print("b = ");
   Serial.println(b);
   Serial.print("pos = ");
   Serial.println(pos);
   Serial.print("buffer = ");
   Serial.println(buffer);*/

  switch (parseState) {
  case PS_DETECT_MSG_TYPE:
    {
      if ( b == '\n' )
        resetBuffer();
      else {
        if ( pos == 3 && strcmp(buffer, "AT+") == 0 ) {
          parseState = PS_IGNORING_COMMAND_ECHO;
        }
        else if ( b == ':' ) {
          //Serial.print("Checking message type: ");
          //Serial.println(buffer);

          if ( strcmp(buffer, "+HTTPACTION:") == 0 ) {
            Serial.println("Received HTTPACTION");
            parseState = PS_HTTPACTION_TYPE;
          }
          else if ( strcmp(buffer, "+HTTPREAD:") == 0 ) {
            Serial.println("Received HTTPREAD");
            parseState = PS_HTTPREAD_LENGTH;
          }
          resetBuffer();
        }
      }
    }
    break;

  case PS_IGNORING_COMMAND_ECHO:
    {
      if ( b == '\n' ) {
        Serial.print("Ignoring echo: ");
        Serial.println(buffer);
        parseState = PS_DETECT_MSG_TYPE;
        resetBuffer();
      }
    }
    break;

  case PS_HTTPACTION_TYPE:
    {
      if ( b == ',' ) {
        Serial.print("HTTPACTION type is ");
        Serial.println(buffer);
        parseState = PS_HTTPACTION_RESULT;
        resetBuffer();
      }
    }
    break;

  case PS_HTTPACTION_RESULT:
    {
      if ( b == ',' ) {
        Serial.print("HTTPACTION result is ");
        Serial.println(buffer);
        parseState = PS_HTTPACTION_LENGTH;
        resetBuffer();
      }
    }
    break;

  case PS_HTTPACTION_LENGTH:
    {
      if ( b == '\n' ) {
        Serial.print("HTTPACTION length is ");
        Serial.println(buffer);

        // now request content
        GSM.print("AT+HTTPREAD=0,");
        GSM.println(buffer);

        parseState = PS_DETECT_MSG_TYPE;
        resetBuffer();
      }
    }
    break;

  case PS_HTTPREAD_LENGTH:
    {
      if ( b == '\n' ) {
        contentLength = atoi(buffer);
        Serial.print("HTTPREAD length is ");
        Serial.println(contentLength);

        Serial.print("HTTPREAD content: ");

        parseState = PS_HTTPREAD_CONTENT;
        resetBuffer();
      }
    }
    break;

  case PS_HTTPREAD_CONTENT:
    {
      // for this demo I'm just showing the content bytes in the serial monitor
      Serial.write(b);

      contentLength--;

      if ( contentLength <= 0 ) {

        // all content bytes have now been read

        parseState = PS_DETECT_MSG_TYPE;
        resetBuffer();

        Serial.print("\n\n\n");

        actionState = AS_IDLE;
      }
    }
    break;
  }
}

When I tested them in separate modules they worked and obtained result But now When I wrote the above code it is showing me "NO GPS DETECTED".Can you please help me in resolving the problem.The objective is I need to obtain the output from GPS at every 5 secs (5 secs interval between each output) and store them into database using GSM module

There are three problems:
1) You are using delay.
2) You are still using SoftwareSerial.  It blocks interrupts for long periods of time, interfering with other parts of your sketch.  I told you this in your previous post.
3) Starting the HTTP action is not synchronized with the GPS clock.  The Arduino millis() clock is not synchronized with the GPS atomic clock.  They will drift in and out of sync over time.  I also told you this in the same previous post.
The solution:
1) Don't use delay.  The GPS device continues to send characters, and they get dropped when the Arduino is blocked at the delay.
Instead, just send the command and let your nice parseATTText handle the response as it comes in, without waiting.  If there are multiple commands to send, add an extra state for each command.  When a response for the first command arrives, send the second command and step to the next state.
You can use delay in setup if you don't care about the responses to those initial commands.  Or you could add one SETUP_xxx state for each command to your FSM and let them happen in loop.  parseATTText will advance through those STARTUP states, sending each of those commands.
2)  Use NeoSWSerial.
3)  Move the HTTPPARA command into the GPS loop with displayInfo:
  while (gps.available( gpsPort )) {
    fix = gps.read();

    // Once every 5 seconds...
    if (++fixCount >= 5) {
      displayInfo();

      // Send the next report if the previous one is finished
      if ( actionState == AS_IDLE ) {
        sprintf(url, "AT+HTTPPARA=\"URL\",\"http://*****.000webhostapp.com/hinderset.php?date=%s\"", dt); // passing date only now as part of testing
        sendGSM(url);
        parseState = PS_HTTPPARA_RESPONSE; // a new state
        actionState = AS_WAITING_FOR_RESPONSE;
      }

      fixCount = 0;
    }
  }

You should move sendGSM("AT+HTTPACTION=0") into parseATTText as a case PS_HTTPPARA_RESPONSE, and step to the next state (PS_DETECT_MSG_TYPE?)
If you reset fixCount inside the if (actionState == IDLE) block, it will send a new location when the previous one finally completes, perhaps after 6 new fixes.
Resetting  fixCount outside the block (as above) means it may send the 5th location, skip the 10th because it's NOT IDLE, and then send the 15th location.  If you want it to send the 5th, then the 11th if it's not busy, reset fixCount inside the if block.

it works fine.ty

I want to store the value of latitude and longitude onto a variable how can i do that.( here it just  prints Serial.print( fix.latitude(), 5 );
Serial.print( ',' );
Serial.print( fix.longitude(), 5 ); ) . I also want to store the speed to a variable how can i do that. when i used sprintf() it failed.

lat, lon and speed are inside the fix structure -- they are already variables.  A structure is just a "group" of variables.  In this case, fix.latitude() is a very simple function that returns the fix.location._lat variable as a float value.  Same with speed: fix.speed_kph() is a simple function that returns the fix.spd... variable's value, converted from knots to kph.  You can use fix (and its member variables) wherever you want, because it is a global, and it is always up-to-date.

If you really want a separate copy of the pieces inside fix, you can declare a second structure: gps_fix oldFix; and copy the current fix into it at some point:  oldFix = fix; // save a snapshot.

I use latitude and longitude for reverse geo and in this i require a precise value i.e about 4 decimal numbers ( like 9.7451 ) .when i use
Serial.print(fix.latitude);  it shows 9.74 .how can i get precise value.

sprintf(url, "AT+HTTPPARA=\"URL\",\"http://masp203.000webhostapp.com/hinder.php?lat=%f&lng=%f&speed=%d&date=%s&time=%s\"",fix.latitude(),fix.longitude(),fix.speed_kph(),dt,tm );       sendGSM(url); When i use it like this it doent work.- Location: 9.74511,76.71756  Speed: 0.15 KMPH   Date : 16/04/2017  Time : 09:12:38-.for these values,in HTTPPARA lat,lng,speed and date value is not correct
Ignoring echo: AT+HTTPPARA="URL","http://masp203.000webhostapp.com/hinder.php?lat=?&lng=?&speed=-18622&date=&time=16/04/2017"

You are using "speed=%d", but passing a floating-point speed_kph() value.  Either pass (int)speed_kph() or change the format specifier to "%f".  I assume you have enabled the "%f" specifier for the printf variants.


text:
why there is errorneous output on start up and how to avoid it?
I wrote an Arduino code to get the latitude,longitude,speed,date and time using the GPS SKG 13BL at every 5 secs and sent it to the database with the help of a php code using GSM 900A.The code is as follows :
#include <NeoSWSerial.h>

#include <AltSoftSerial.h>
#include <NMEAGPS.h>

NeoSWSerial GSM(2, 3); // RX, TX: Connect TXD to RX & RXD to TX

static const int RXPin = 8, TXPin = 9;
AltSoftSerial gpsPort(RXPin, TXPin);
static const uint32_t GPSBaud = 9600;

NMEAGPS gps;
gps_fix fix;
uint8_t fixCount = 0;
char dt[15],tm[15],lati[10],longi[10];

enum _parseState {
  PS_DETECT_MSG_TYPE,

  PS_IGNORING_COMMAND_ECHO,

  PS_HTTPPARA_RESPONSE,

  PS_HTTPACTION_TYPE,
  PS_HTTPACTION_RESULT,
  PS_HTTPACTION_LENGTH,

  PS_HTTPREAD_LENGTH,
  PS_HTTPREAD_CONTENT
};

enum _actionState {
  AS_IDLE,
  AS_WAITING_FOR_RESPONSE
};

byte actionState = AS_IDLE;
unsigned long lastActionTime = 0;

int s;

byte parseState = PS_DETECT_MSG_TYPE;
char buffer[160],url[160];
byte pos = 0;

int contentLength = 0;

void resetBuffer() {
  memset(buffer, 0, sizeof(buffer));
  pos = 0;
}

void sendGSM(const char* msg, int waitMs = 500) {
  GSM.println(msg);
  while(GSM.available()) {
    parseATText(GSM.read());
  }
  //delay(waitMs);
}

void setup()
{
  GSM.begin(9600);
  Serial.begin(9600);
  gpsPort.begin(GPSBaud);

  Serial.println(F("Hinder LOADING....."));
  Serial.println(F("obtain gps and store data to database"));
  Serial.println(F("Testing by : "));
  Serial.println(F("Nikhil,Muthumani and Mathews"));
  Serial.println();

  sendGSM("AT+SAPBR=3,1,\"APN\",\"vodafone\"");
  delay(500);
  sendGSM("AT+SAPBR=1,1",3000);
  delay(500);
  sendGSM("AT+HTTPINIT");
  delay(500);
  sendGSM("AT+HTTPPARA=\"CID\",1");
  delay(500);
}

void loop()
{
  unsigned long now = millis();
  while (gps.available( gpsPort )) {
    fix = gps.read();
     //Serial.println(F("b"));
    // Once every 5 seconds...
    if (++fixCount >= 5) {
       //Serial.println(F("a"));
      displayInfo();

      //send the next report if previous one is finished
      if ( actionState == AS_IDLE ) {
      sprintf(url, "AT+HTTPPARA=\"URL\",\"http://********.com/***er.php?lat=%s&lng=%s&speed=%d&date=%s&time=%s\"",lati,longi,s,dt,tm );
      sendGSM(url);
     // lastActionTime = now;
      parseState = PS_HTTPPARA_RESPONSE; // a new state
      actionState = AS_WAITING_FOR_RESPONSE;
      fixCount = 0;
    }

    }
  }

/*  if ((gps.statistics.chars < 10) && (millis() > 5000)) {
     Serial.println( F("No GPS detected: check wiring.") );
     while(true);
     block=1;
    }*/

  while(GSM.available()) {
    //lastActionTime = now;
    parseATText(GSM.read());
  }
 }

void displayInfo()
{
  Serial.print(F("Location: "));
  if (fix.valid.location) {
    dtostrf( fix.latitude(),7,5,lati);
    //sprintf(lati,"%d",fix.latitude(),5);
    Serial.print(lati);
    Serial.print( ',' );
    dtostrf( fix.longitude(),8,5,longi);
    //sprintf(longi,"%d",fix.longitude(),5);
    Serial.print(longi);
  } else {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Speed: "));
  if (fix.valid.speed) {
    s=fix.speed_kph();
    Serial.print(s);
    Serial.print(F(" KMPH "));
  } else {
    Serial.print(F("INVALID"));
  }

  // Shift the date/time to local time
  NeoGPS::clock_t localSeconds;
  NeoGPS::time_t  localTime;
  if (fix.valid.date && fix.valid.time) {
    using namespace NeoGPS; // save a little typing below...

    localSeconds = (clock_t) fix.dateTime; // convert structure to a second count
    localSeconds += 5 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE; // shift timezone
    localTime = localSeconds;              // convert back to a structure
  }

  Serial.print(F("  Date : "));
  if (fix.valid.date) {
    sprintf(dt,"%02d/%02d/20%d",fix.dateTime.date,fix.dateTime.month,fix.dateTime.year);
    Serial.print(dt);
  } else {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Time : "));
  if (fix.valid.time) {
    if (localTime.hours>12)localTime.hours-=12;//To convert 24 hr format to 12 hr format
    sprintf(tm,"%02d:%02d:%02d",localTime.hours,localTime.minutes,localTime.seconds);
    Serial.print(tm);
    //block=1;
  } else {
    Serial.print(F("INVALID"));
  }

  Serial.println();
}

void parseATText(byte b) {

  buffer[pos++] = b;

  if ( pos >= sizeof(buffer) )
    resetBuffer(); // just to be safe

  /*
   // Detailed debugging
   Serial.println();
   Serial.print("state = ");
   Serial.println(state);
   Serial.print("b = ");
   Serial.println(b);
   Serial.print("pos = ");
   Serial.println(pos);
   Serial.print("buffer = ");
   Serial.println(buffer);*/

  switch (parseState) {

  case PS_HTTPPARA_RESPONSE:
    {
      parseState = PS_DETECT_MSG_TYPE;
      sendGSM("AT+HTTPACTION=0");
     /*  while(GSM.available()) {
    //lastActionTime = now;
    parseATText(GSM.read());
  }*/

    }
    break;

  case PS_DETECT_MSG_TYPE:
    {
      if ( b == '\n' )
        resetBuffer();
      else {
        if ( pos == 3 && strcmp(buffer, "AT+") == 0 ) {
          parseState = PS_IGNORING_COMMAND_ECHO;
        }
        else if ( b == ':' ) {
          //Serial.print("Checking message type: ");
          //Serial.println(buffer);

          if ( strcmp(buffer, "+HTTPACTION:") == 0 ) {
            Serial.println("Received HTTPACTION");
            parseState = PS_HTTPACTION_TYPE;
          }
          else if ( strcmp(buffer, "+HTTPREAD:") == 0 ) {
            Serial.println("Received HTTPREAD");
            parseState = PS_HTTPREAD_LENGTH;
          }
          resetBuffer();
        }
      }
    }
    break;

  case PS_IGNORING_COMMAND_ECHO:
    {
      if ( b == '\n' ) {
        Serial.print("Ignoring echo: ");
        Serial.println(buffer);
        parseState = PS_DETECT_MSG_TYPE;
        resetBuffer();
      }
    }
    break;

  case PS_HTTPACTION_TYPE:
    {
      if ( b == ',' ) {
        Serial.print("HTTPACTION type is ");
        Serial.println(buffer);
        parseState = PS_HTTPACTION_RESULT;
        resetBuffer();
      }
    }
    break;

  case PS_HTTPACTION_RESULT:
    {
      if ( b == ',' ) {
        Serial.print("HTTPACTION result is ");
        Serial.println(buffer);
        parseState = PS_HTTPACTION_LENGTH;
        resetBuffer();
      }
    }
    break;

  case PS_HTTPACTION_LENGTH:
    {
      if ( b == '\n' ) {
        Serial.print("HTTPACTION length is ");
        Serial.println(buffer);

        // now request content
        GSM.print("AT+HTTPREAD=0,");
        GSM.println(buffer);

        parseState = PS_DETECT_MSG_TYPE;
        resetBuffer();
      }
    }
    break;

  case PS_HTTPREAD_LENGTH:
    {
      if ( b == '\n' ) {
        contentLength = atoi(buffer);
        Serial.print("HTTPREAD length is ");
        Serial.println(contentLength);

        Serial.print("HTTPREAD content: ");

        parseState = PS_HTTPREAD_CONTENT;
        resetBuffer();
      }
    }
    break;

  case PS_HTTPREAD_CONTENT:
    {
      // for this demo I'm just showing the content bytes in the serial monitor
      Serial.write(b);

      contentLength--;

      if ( contentLength <= 0 ) {

        // all content bytes have now been read

        parseState = PS_DETECT_MSG_TYPE;
        resetBuffer();

        Serial.print("\n\n\n");

        actionState = AS_IDLE;
      }
    }
    break;
  }
}

When I test the code it shows the output as :  as you can see after Ignoring echo: AT+HTTPREAD=0,0
the GPS output is printed out at every sec (not at 5 sec interval) and also does not perform rest of the actions (i.e Sending to database is not performed). And I press reset button  and the output is : Even though it prints the GPS output at every sec it inserted the values into database.And once again I press reset button then it works fine.So why do this error occurs and is there a way to solve this.And can I make the program run only when GPS data is available (because now if GPS data is not available it shows some error nature ).

:)

Why does this error occur, and is there a way to solve this?

Because the GSM operations take time, the GPS data has time to accumulate.  Then the while (gps.available loop will execute multiple times without breaking.  It calls displayInfo every time because fixCount >= 5.  fixCount is 6, 7, 8, etc. in consecutive seconds.
To solve this problem, you need to be more restrictive about starting the sending process:
void loop()
{
  while (gps.available( gpsPort )) {
    fix = gps.read();
     //Serial.println(F("b"));

    //send a report once every 5 seconds if previous one is finished
    if ((++fixCount >= 5) && (actionState == AS_IDLE)) {

      //Serial.println(F("a"));
      displayInfo();

      sprintf(url, "AT+HTTPPARA=\"URL\",\"http://********.com/***er.php?lat=%s&lng=%s&speed=%d&date=%s&time=%s\"",lati,longi,s,dt,tm );
      sendGSM(url);
      parseState  = PS_HTTPPARA_RESPONSE; // a new state
      actionState = AS_WAITING_FOR_RESPONSE;
      fixCount    = 0;
    }
  }

  while(GSM.available()) {
    parseATText(GSM.read());
  }
}

The combined if test displays GPS info only when the GSM process begins.  Then it will continue to read fixes, keeping the queue emptied.  When the state goes back to AS_IDLE, it can send another update.  Notice how this loop structure will continue counting fixes while the GSM process is completing.  If the GSM process takes 5 seconds or more, it will immediately send another update when the previous GSM send has completed.
If you want it to wait an additional 5 seconds between each GSM update, don't increment the fixCount until the GSM process has completed (AS_IDLE).  Then the updates will be sent once every 5 + (GSM send time) seconds, perhaps once every 15 seconds.

can I make the program run only when GPS data is available (because now if GPS data is not available it shows some error nature ).

Yes, make the if test even more restrictive by testing the valid flags:
    //send a report once every 5 seconds if the data is valid
    //   and the previous one is finished
    if ((fix.valid.location && fix.valid.date && fix.valid.time) &&
        (++fixCount >= 5) &&
        (actionState == AS_IDLE)) {

This only counts valid fixes; the fixCount will not increment unless those 3 pieces are valid.
NOTE: You probably don't have to test fix.valid.speed, as it will be marked as invalid when you are stationary.  Testing the valid flags could be removed from displayInfo():
void displayInfo()
{
  Serial.print(F("Location: "));
  dtostrf( fix.latitude(),7,5,lati);
  Serial.print(lati);
  Serial.print( ',' );
  dtostrf( fix.longitude(),8,5,longi);
  Serial.print(longi);

  Serial.print(F("  Speed: "));
  if (fix.valid.speed) {
    s=fix.speed_kph();
  } else {
    s=0;
  }
  Serial.print(s);
  Serial.print(F(" KMPH "));

  // Shift the date/time to local time
  NeoGPS::clock_t localSeconds;
  NeoGPS::time_t  localTime;
  {
    using namespace NeoGPS; // save a little typing below...

    localSeconds = (clock_t) fix.dateTime; // convert structure to a second count
    localSeconds += 5 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE; // shift timezone
    localTime = localSeconds;              // convert back to a structure
  }

  Serial.print(F("  Date : "));
  sprintf(dt,"%02d/%02d/20%d",fix.dateTime.date,fix.dateTime.month,fix.dateTime.year);
  Serial.print(dt);

  Serial.print(F("  Time : "));
  if (localTime.hours>12)localTime.hours-=12;//To convert 24 hr format to 12 hr format
  sprintf(tm,"%02d:%02d:%02d",localTime.hours,localTime.minutes,localTime.seconds);
  Serial.print(tm);
  //block=1;

  Serial.println();
}

displayInfo still checks fix.valid.speed and uses 0 when there is no speed (i.e., when you're stationary).


text:
how to get precise value from float variable?
#include <NeoSWSerial.h>

//#include <SoftwareSerial.h>
#include <AltSoftSerial.h>
#include <NMEAGPS.h>

NeoSWSerial GSM(2, 3); // RX, TX: Connect TXD to RX & RXD to TX

static const int RXPin = 8, TXPin = 9;
AltSoftSerial gpsPort(RXPin, TXPin);
static const uint32_t GPSBaud = 9600;

NMEAGPS gps;
gps_fix fix;
uint8_t fixCount = 0;
char dt[15],tm[15];
float lati,longi;
//int block = 0;

enum _parseState {
  PS_DETECT_MSG_TYPE,

  PS_IGNORING_COMMAND_ECHO,

  PS_HTTPPARA_RESPONSE,

  PS_HTTPACTION_TYPE,
  PS_HTTPACTION_RESULT,
  PS_HTTPACTION_LENGTH,

  PS_HTTPREAD_LENGTH,
  PS_HTTPREAD_CONTENT
};

enum _actionState {
  AS_IDLE,
  AS_WAITING_FOR_RESPONSE
};

byte actionState = AS_IDLE;
unsigned long lastActionTime = 0;

float s;

byte parseState = PS_DETECT_MSG_TYPE;
char buffer[160],url[160];
byte pos = 0;

int contentLength = 0;

void resetBuffer() {
  memset(buffer, 0, sizeof(buffer));
  pos = 0;
}

void sendGSM(const char* msg, int waitMs = 500) {
  GSM.println(msg);
  while(GSM.available()) {
    parseATText(GSM.read());
  }
  //delay(waitMs);
}

void setup()
{
  GSM.begin(9600);
  Serial.begin(9600);
  gpsPort.begin(GPSBaud);

  Serial.println(F("Hinder LOADING....."));
  Serial.println(F("obtain gps and store data to database"));
  Serial.println(F("Testing by : "));
  Serial.println(F("Nikhil,Muthumani and Mathews"));
  Serial.println();

  sendGSM("AT+SAPBR=3,1,\"APN\",\"vodafone\"");
  delay(500);
  sendGSM("AT+SAPBR=1,1",3000);
  delay(500);
  sendGSM("AT+HTTPINIT");
  delay(500);
  sendGSM("AT+HTTPPARA=\"CID\",1");
  delay(500);
}

void loop()
{
  unsigned long now = millis();
  while (gps.available( gpsPort )) {
    fix = gps.read();
     //Serial.println(F("b"));
    // Once every 5 seconds...
    if (++fixCount >= 5) {
       //Serial.println(F("a"));
      displayInfo();

      //send the next report if previous one is finished
      if ( actionState == AS_IDLE ) {
      sprintf(url, "AT+HTTPPARA=\"URL\",\"http://**************/***.php?lat=%d&lng=%d&speed=%d&date=%s&time=%s\"",lati,longi,s,dt,tm );
      sendGSM(url);
     // lastActionTime = now;
      parseState = PS_HTTPPARA_RESPONSE; // a new state
      actionState = AS_WAITING_FOR_RESPONSE;
      fixCount = 0;
    }

    }
  }

/*  if ((gps.statistics.chars < 10) && (millis() > 5000)) {
     Serial.println( F("No GPS detected: check wiring.") );
     while(true);
     block=1;
    }*/

  while(GSM.available()) {
    //lastActionTime = now;
    parseATText(GSM.read());
  }
 }

void displayInfo()
{
  Serial.print(F("Location: "));
  if (fix.valid.location) {
    lati=( fix.latitude());
    //sprintf(lati,"%d",fix.latitude(),5);
    Serial.print(lati);
    Serial.print( ',' );
    longi= ( fix.longitude());
    //sprintf(longi,"%d",fix.longitude(),5);
    Serial.print(longi);
  } else {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Speed: "));
  if (fix.valid.speed) {
    s=fix.speed_kph();
    Serial.print(s);
    Serial.print(F(" KMPH "));
  } else {
    Serial.print(F("INVALID"));
  }

  // Shift the date/time to local time
  NeoGPS::clock_t localSeconds;
  NeoGPS::time_t  localTime;
  if (fix.valid.date && fix.valid.time) {
    using namespace NeoGPS; // save a little typing below...

    localSeconds = (clock_t) fix.dateTime; // convert structure to a second count
    localSeconds += 5 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE; // shift timezone
    localTime = localSeconds;              // convert back to a structure
  }

  Serial.print(F("  Date : "));
  if (fix.valid.date) {
    sprintf(dt,"%02d/%02d/20%d",fix.dateTime.date,fix.dateTime.month,fix.dateTime.year);
    Serial.print(dt);
  } else {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Time : "));
  if (fix.valid.time) {
    if (localTime.hours>12)localTime.hours-=12;//To convert 24 hr format to 12 hr format
    sprintf(tm,"%02d:%02d:%02d",localTime.hours,localTime.minutes,localTime.seconds);
    Serial.print(tm);
    //block=1;
  } else {
    Serial.print(F("INVALID"));
  }

  Serial.println();
}

void parseATText(byte b) {

  buffer[pos++] = b;

  if ( pos >= sizeof(buffer) )
    resetBuffer(); // just to be safe

  /*
   // Detailed debugging
   Serial.println();
   Serial.print("state = ");
   Serial.println(state);
   Serial.print("b = ");
   Serial.println(b);
   Serial.print("pos = ");
   Serial.println(pos);
   Serial.print("buffer = ");
   Serial.println(buffer);*/

  switch (parseState) {

  case PS_HTTPPARA_RESPONSE:
    {
      parseState = PS_DETECT_MSG_TYPE;
      sendGSM("AT+HTTPACTION=0");
     /*  while(GSM.available()) {
    //lastActionTime = now;
    parseATText(GSM.read());
  }*/

    }
    break;

  case PS_DETECT_MSG_TYPE:
    {
      if ( b == '\n' )
        resetBuffer();
      else {
        if ( pos == 3 && strcmp(buffer, "AT+") == 0 ) {
          parseState = PS_IGNORING_COMMAND_ECHO;
        }
        else if ( b == ':' ) {
          //Serial.print("Checking message type: ");
          //Serial.println(buffer);

          if ( strcmp(buffer, "+HTTPACTION:") == 0 ) {
            Serial.println("Received HTTPACTION");
            parseState = PS_HTTPACTION_TYPE;
          }
          else if ( strcmp(buffer, "+HTTPREAD:") == 0 ) {
            Serial.println("Received HTTPREAD");
            parseState = PS_HTTPREAD_LENGTH;
          }
          resetBuffer();
        }
      }
    }
    break;

  case PS_IGNORING_COMMAND_ECHO:
    {
      if ( b == '\n' ) {
        Serial.print("Ignoring echo: ");
        Serial.println(buffer);
        parseState = PS_DETECT_MSG_TYPE;
        resetBuffer();
      }
    }
    break;

  case PS_HTTPACTION_TYPE:
    {
      if ( b == ',' ) {
        Serial.print("HTTPACTION type is ");
        Serial.println(buffer);
        parseState = PS_HTTPACTION_RESULT;
        resetBuffer();
      }
    }
    break;

  case PS_HTTPACTION_RESULT:
    {
      if ( b == ',' ) {
        Serial.print("HTTPACTION result is ");
        Serial.println(buffer);
        parseState = PS_HTTPACTION_LENGTH;
        resetBuffer();
      }
    }
    break;

  case PS_HTTPACTION_LENGTH:
    {
      if ( b == '\n' ) {
        Serial.print("HTTPACTION length is ");
        Serial.println(buffer);

        // now request content
        GSM.print("AT+HTTPREAD=0,");
        GSM.println(buffer);

        parseState = PS_DETECT_MSG_TYPE;
        resetBuffer();
      }
    }
    break;

  case PS_HTTPREAD_LENGTH:
    {
      if ( b == '\n' ) {
        contentLength = atoi(buffer);
        Serial.print("HTTPREAD length is ");
        Serial.println(contentLength);

        Serial.print("HTTPREAD content: ");

        parseState = PS_HTTPREAD_CONTENT;
        resetBuffer();
      }
    }
    break;

  case PS_HTTPREAD_CONTENT:
    {
      // for this demo I'm just showing the content bytes in the serial monitor
      Serial.write(b);

      contentLength--;

      if ( contentLength <= 0 ) {

        // all content bytes have now been read

        parseState = PS_DETECT_MSG_TYPE;
        resetBuffer();

        Serial.print("\n\n\n");

        actionState = AS_IDLE;
      }
    }
    break;
  }
}

in this I try obtain the GPS latitude and longitude at every 5 secs and and use that values to find the name of the location.I need to pass the value of latitude and longitude over the URL to the php code and there it is converted to the location name.I also need to pass the speed,date and time (speed and date works fine). When i try to sent them the command displayed on the window is Ignoring echo: AT+HTTPPARA="URL","http://[link]/hinder.php?lat=?&lng=?&speed=?&date=&time=16/04/2017" here you can see instead of value of latitude,speed and longitude a question mark appears.So i tried
sprintf(url, "AT+HTTPPARA=\"URL\",\"http://masp203.000webhostapp.com/hinder.php?lat=%f&lng=%f&speed=%d&date=%s&time=%s\"",fix.latitude(),fix.longitude(),fix.speed_kph(),dt,tm ); sendGSM(url);

but that too didnt worked.I need a presice value of latitude and longitude (about 5 decimal points) since it is used to find the location.Can any one tell me hoe can i do that .

Floating point values aren't precise.
However you problem has nothing to do with precision, but purely how you are representing the value as text. You are asking for the format %f which, by default on Arduino, is not supported by sprintf.
Instead you have to use the function dtostrf() (a non-standard libavr specific function).
char floatval[10]; // Room for 9 characters + NULL
float myVal = 48.53927853;

dtostrf(myVal, 9, 5, floatval);

Selection of the right numbers is critical. The first is the total space you have available in the target character array (not including the required NULL, so one less than the size of the array). The second is the number of decimal places to render. So you have to make sure you have enough room for the integer portion, any sign (if it's negative) and the decimal point, plus the number of decimal places you want to render - in this case:

1 - Sign
2 - Integer
1 - Decimal point
5 - Decimal portion

Total: 1+2+1+5 = 9.
The first value, width, can also be given as a negative value, in which case left alignment of the content will be performed.

how can i make use of dtostrf() function in my url (sprintf(url, "AT+HTTPPARA=\"URL\",\"http://masp203.000webhostapp.com/hinder.php?lat=%f&lng=%f&speed=%d&date=%s&time=%s\"",fix.latitude(),fix.longitude(),fix.speed_kph(),dt,tm ); sendGSM(url);.Can u explain it with my example

You could use format %s to insert the string, or you could not use sprintf() at all and build it up piecemeal using strcat(), etc.

it works fine!!

If you aren't going to be computing with the GPS coordinates, I'd suggest keeping the character strings just as they were delivered by the device. You'll keep all of the precision available without introducing any quantization or roundoff errors.

how to get precise value from float variable?

possible solutions:
1) don't use float where precise values are needed - by far the best solution;
2) use fixed point types;
3) use integer types;
...

I need a precise value of latitude and longitude (about 5 decimal points) since it is used to find the location.  Can any one tell me how can I do that.

If you only need 5 decimal points, you can continue to use float values.  If you would like more precision, you can use the 32-bit integer forms of lat/lon provided by NeoGPS.
For float values, you can do as Majenko suggested.  Just like the date and time arrays, you format that floating-point lat and lon values into their own character arrays.  Then put them in the url array with sprintf and "%s", just like the dt and tm arrays.
To get the extra digits of precision, you have to use the fix.latitudeL() and fix.longitudeL() functions.  They return integers that have 10 significant digits.  They are scaled by 10000000, so you have to insert the decimal point at the right place.  The example program NMEAloc.ino shows how to print those integers as if they were floating-point values.
Since you are using sprintf, you could format latitude like this:
char lat[16];
int deg = fix.latitudeL() / 10000000L; // possibly negative
int decimals = abs( fix.latitude() - deg * 10000000L );
sprintf( lat, "%d.%07d", deg, decimals );

Then format this into the url array with %s:
sprintf( url, " ... &lat=%s&...", ... , lat, ... );

That gives you 7 decimals, like 9.7451145