Using float(), data will be in the form 0.xxxxxxxx

Hello,
I make projects with accelerometer sensor. My data is in the form of 0.xx. I used the function float() to show more details of the data. However, I couldn’t do it. So could you please guide me to display the data as 0.xxxxxxxxx?
Thank you

#include <Wire.h>
#include <ADXL345.h>

ADXL345 accel(ADXL345_STD);

void setup() {
  Serial.begin(9600); //le baud rate, initialisation série
  Wire.begin();
  delay(1000);

  byte deviceID = accel.readDeviceID();
  if (deviceID != 0) {
    Serial.print("0x");
    Serial.print(deviceID, HEX);
    Serial.println("");
  } else {
    Serial.println("read device id: failed");
    while(1) {
      delay(100);
    }
  }

  // Data Rate
  // - ADXL345_RATE_3200HZ: 3200 Hz
  // - ADXL345_RATE_1600HZ: 1600 Hz
  // - ADXL345_RATE_800HZ:  800 Hz
  // - ADXL345_RATE_400HZ:  400 Hz
  // - ADXL345_RATE_200HZ:  200 Hz
  // - ADXL345_RATE_100HZ:  100 Hz
  // - ADXL345_RATE_50HZ:   50 Hz
  // - ADXL345_RATE_25HZ:   25 Hz
  // - ...
  if (!accel.writeRate(ADXL345_RATE_1600HZ)) {
    Serial.println("write rate: failed");
    while(1) {
      delay(1000);
    }
  }

  // Data Range, On peut choisir +-2 g 
  // - ADXL345_RANGE_2G: +-2 g
  // - ADXL345_RANGE_4G: +-4 g
  // - ADXL345_RANGE_8G: +-8 g
  // - ADXL345_RANGE_16G: +-16 g
  if (!accel.writeRange(ADXL345_RANGE_2G)) {
    Serial.println("write range: failed");
    while(1) {
      delay(100);
    }
  }

  if (!accel.start()) {
    Serial.println("start: failed");
    while(1) {
      delay(100);
    }
  }
}
void write_float(float value);
float myfloat;
float read_float();
float a;
float b;
float c;

void loop() {
  if (accel.update()) {
    a=accel.getX(); \\ ox
    b=accel.getY(); \\ oy
    c=accel.getZ(); \\ oz
    Serial.print(a);//Afficher les composants d'accélération dans le moniteur série
    Serial.print("\t"); // tabulation
    Serial.print(b);
    Serial.print("\t");
    Serial.print(c);
    Serial.println("");
  } else {
    Serial.println("update failed");
    while(1) {
      delay(100);
    }
  }
  delay(5);// 5ms 
}

See the word "DOCUMENTATION" at the top of your screen. Click on that and continue to "Serial". Then to Serial.print() and in there you will see examples of using the second parameter for Serial.print() that will change the number of decimal places that will display.

Paul

Paul_KD7HB:
See the word "DOCUMENTATION" at the top of your screen. Click on that and continue to "Serial". Then to Serial.print() and in there you will see examples of using the second parameter for Serial.print() that will change the number of decimal places that will display.

Paul

Thanks sir, I found what I wanted.