Saving into internal memory

Hello everyone, i have a coding question… I am currently doing a project about positioning. I am using the Processing application to display the movements and the coordinates of my device, also i’ve added some extra features ( creating a flight path ) As you can see below…

image

But now i am thinking is it possible to store the information when an external trigger is being input-ed by the user in the serial monitor.

 char rx_byte = 0;
  int z;
  coordinates_t coor;
int  a = coor.x;
int  b = coor.y;
int  c = coor.z;
const coordinates_t SavedCoordinates[] PROGMEM = {};

   if (Serial.available() > 0) {    // is a character available?
    rx_byte = Serial.read();       // get the character
  
    if ((rx_byte == '1')) {
      Serial.print(" START RECORDING \n");
    const coordinates_t SavedCoordinates[] PROGMEM = {};
    
    }
    else if (rx_byte == '2'){
      Serial.println(" STOP RECORDING ");
    }
    else 
    {
      Serial.println(" Invalid Input ");
    }  
}

coor.x, coor.y and coor.z is the variables that hold my coordinates value… I was thinking when the user input a ’ 1’ into the serial monitor the " START RECORDING " words will be printed in the serial monitor and wherever i move my device, ALL the coordinates will be stored inside the memory of the board ( it can be any memory, it can be flash,SRAM, EEPROM ) until a ‘2’ is input-ed and the " STOP RECORDING " is printed. Meaning all the coordinates data in between the start and stop recording is to be saved in the internal memory… Any one knows if it is possible.? please help me … Thank you very much

1 Like

i think:

  • that is a pure arduino question
    ( using arduino IDE monitor and a USB connected arduino with some ?GPS? hardware )

  • so it is a little bit misplaced at the processing forum
    while a combination of processing and arduino code ( as a complete project is welcome )

  • using arduino local memory

    • progmem ( flash ) ( your example )
    • RAM like in a normal array ( lost at reboot )
    • EEPROM not so easy but good as data are not lost
    • there are some HAT’s with uSD card slot or more eeprom…
  • to collect data and send them later is usual practice
    ( like a oscilloscope reading analog / writing serial port would do ?400Hz?
    a reading batch to array ( i do 360 samples as fast as possible )
    and sending the batch to processing after that, get me up to 8kHz (batch) sampling rate one channel only

what i worry is that you have a concept in mind like

  • send a “start”
  • shutdown or disconnect processing computer
  • let it sample for a certain time
  • connect again and read out the data

so i have to warn you that

  • shutdown ( i never see that anywhere mentioned )

AND

  • connect

serial interface will reboot the arduino!
means your arduino sample logic ( and data ) must survive 2 reboots!

1 Like