how to save data into the buffer?

Hello to everyone

i am trying to save data in the SDcard

but i have a problem with saving data into the buffer
for a example, v = 10
if i would like to save this value into the buffer
and save into the SDcard that would be 10

how to save into the buffer in the first place ?

Thanks a lot :slight_smile:

Tp little context to give useful answer. Perhaps you could post the code you're having problems with.

i am sorry, here is the code

i have trying to save the value of v that determined by the code

#include <sd-reader_config.h>
#include <sd_raw.h>
#include <sd_raw_config.h>
#include <byteordering.h>
#include <fat.h>
#include <FAT16.h>
#include <fat_config.h>
#include <partition.h>
#include <partition_config.h>
#define FREQ_PIN 3
#include <LiquidCrystal.h>

FAT TestFile;      //This will be the file we manipulate in the sketch
char buffer[512];  //Data will be temporarily stored to this buffer before being written to the file
int read_size=0;   //Used as an indicator for how many characters are read from the file
int count=0;       //Miscellaneous variable

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
  pinMode(FREQ_PIN, INPUT);
 lcd.begin(16, 2);
 TestFile.initialize();
 TestFile.create_file("Velocity Record.txt");
 TestFile.open();
 }

void loop() 
{
unsigned long t1 = pulseIn(FREQ_PIN, HIGH);// Time how long it takes to go HIGH again
unsigned long t2 = pulseIn(FREQ_PIN, LOW); // and how long it takes to go low again.
 double t = t1 + t2;
         double f = 1000000.0/t;
           double w = 2 * 3.14 * f;
           double v = w * 0.05;
       lcd.setCursor(0,0);
         lcd.println(v);
         delay(2000);
TestFile.write("The velocity of the wheel");  //using the write function will always write to the beginning of the file. 
                                         // Here we add some text to the file.
                                        // Here we add some text to the file.
  TestFile.close();  //We are done writing to the file for now. Close it for later use.

  while(1)
    TestFile.open();  //Open the file. When the file is opened we will be looking at the beginning of the file.
    read_size=TestFile.read(buffer); //Read the contents of the file. This will only read the amount of data s
read_size=TestFile.read(buffer); //Read the contents of the file. This will only read the amount of data specified
                                    // by the size of 'buffer.'
sprintf(buffer, "%d", count++); //Now we'll use the buffer to write data back to the file. 
                                   // Here's we'll only add one value to buffer, the 'count' variable. 
    TestFile.write(buffer);         //Write the new buffer to the end of the file
    TestFile.close();               //Close the file for later use.

    delay(1000);  //Wait one second before repeating the loop.

}

it is showing this error

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\SDcard/sd_raw_config.h:86:6: error: #error "no sd/mmc pin mapping available!"

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/fat.h:89: error: 'offset_t' does not name a type

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/fat.h:117: error: 'offset_t' does not name a type

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/fat.h:118: error: 'offset_t' does not name a type

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:83: error: typedef 'device_read_t' is initialized (use typeof instead)

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:83: error: 'offset_t' was not declared in this scope

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:83: error: expected primary-expression before '*' token

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:83: error: 'buffer' was not declared in this scope

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:83: error: expected primary-expression before 'length'

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:92: error: 'offset_t' has not been declared

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:111: error: typedef 'device_read_interval_t' is initialized (use typeof instead)

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:111: error: 'offset_t' was not declared in this scope

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:111: error: expected primary-expression before '*' token

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:111: error: 'buffer' was not declared in this scope

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:111: error: expected primary-expression before 'interval'

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:111: error: expected primary-expression before 'length'

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:111: error: expected primary-expression before 'callback'

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:111: error: expected primary-expression before 'void'

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:119: error: typedef 'device_write_t' is initialized (use typeof instead)

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:119: error: 'offset_t' was not declared in this scope

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:119: error: expected primary-expression before 'const'

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:119: error: expected primary-expression before 'length'

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:129: error: 'offset_t' has not been declared

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:148: error: typedef 'device_write_interval_t' is initialized (use typeof instead)

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:148: error: 'offset_t' was not declared in this scope

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:148: error: expected primary-expression before '*' token

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:148: error: 'buffer' was not declared in this scope

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:148: error: expected primary-expression before 'length'

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:148: error: expected primary-expression before 'callback'

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:148: error: expected primary-expression before 'void'

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:161: error: 'device_read_t' does not name a type

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:168: error: 'device_read_interval_t' does not name a type

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:175: error: 'device_write_t' does not name a type

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:182: error: 'device_write_interval_t' does not name a type

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:200: error: 'device_read_t' was not declared in this scope

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:200: error: 'device_read_interval_t' was not declared in this scope

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:200: error: 'device_write_t' was not declared in this scope

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:200: error: 'device_write_interval_t' was not declared in this scope

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:200: error: expected primary-expression before 'index'

C:\Users\Max\Documents\Arduino\Arduino\arduino-0018\libraries\FAT/partition.h:200: error: initializer expression list treated as compound expression

In function 'void setup()':
Bad error line: -2