SD Card errors

Attempting to append a integer onto a file on the SD card, receives the error

error: cannot initialize a parameter of type ‘uint8_t *’ (aka ‘unsigned char *’) with an lvalue of type ‘uint8_t’ (aka ‘unsigned char’)

when compiling the code below

  int x = Motor1.velocity(pct);
  uint8_t y = x;
  int bytes = Brain.SDcard.appendfile(targetFile, y, 3);
  if (bytes <= 0) {
    Brain.Screen.print("0 Byte Write Error");
    Controller1.Screen.print("0 BYTE ERR");

Any assistance is appreciated.

the sdcard functions all require a buffer pointer, not values like you are passing. If you really want to write binary data, it might be something like this.

    int x = 23;

    Brain.SDcard.appendfile("file", (uint8_t *)&x, sizeof(int) );

to write the values as text, you need to convert to a string.

    int x = 23;
    char  buffer[32];
    sprintf(buffer, "%d", x );
    Brain.SDcard.appendfile("file", (uint8_t *)buffer, strlen(buffer) );

make sure the file exists if you want to use appendfile