Go Down

Topic: Storing incoming data from serial port (Read 557 times) previous topic - next topic

HC1234

Hey!!

I have some data coming in from the serial port and i want to manipulate the data further only i have no idea how to store/save the incoming data so i can further use it in the program.

Any suggestions would be highly appreciated.
Thanks in advance

johnwasser

It depends on how large a chunk of data you are manipulating.

If you are changing each character individually, don't store the data.

If you have a little data, say a line of characters at a time, store it in an array (SRAM), manipulate that line, and send it out.

If you have a LOT of data, say several thousand characters, you can store them on an SD card (you will need to add hardware).  Then you can read and write the SD card.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

HC1234

For some reason when i try to store the data in an array, lots of spaces get included. Can u tell me what i'm doing wrong??
I'm attaching the code i'm using before and after.

Any help would be great.
Thanks in advance

CrossRoads

These only look to see if you have more than 0 bytes (i.e. 1), but then write out 51 bytes.
Change the code to only write a byte into array when one has come in, increment a counter to stop writing data in when 50 bytes have been received.

  if (mySerial.available())
    Serial.write(mySerial.read());

  if (Serial.available()>0)
    {
      for (i=0; i<51; i++)
      outputs = Serial.read();
     }
   
   for (i=0; i<51; i++)
   Serial.println(outputs);

}
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

HC1234

Oh ya!! LOL!! Thankyou so much!!!!  :)  :)

Go Up