What to do if the #include function does not work inside the code of my Arduino Board Mega 2560 Here is the code:

#include <"CurieIMU.h">;
CurieIMU.readMotionSensor(ax, ay, az, gx, gy, gz);

int ax, ay, az;         // accelerometer values
int gx, gy, gz;         // gyrometer values

int axBrightness = 0;
int axLed = 9;

int ayBrightness = 0;
int ayLed = 6;

int azBrightness = 0;
int azLed = 5;

void setup(){

  pinMode(axLed, OUTPUT); 
  pinMode(ayLed, OUTPUT); 
  Serial.begin(9600); // initialize Serial communication
  delay(5000); // Allow the user to set everything down
  CurieIMU.autoCalibrateAccelerometerOffset(X_AXIS, 0);
  CurieIMU.autoCalibrateAccelerometerOffset(Y_AXIS, 0);
  CurieIMU.autoCalibrateAccelerometerOffset(Z_AXIS, 0);

String jsonEncodeValue(String key, float keyVal){
  return "\"" + key + "\":" + String(keyVal) + "";

String assembleJson(String keysAndVals){
  return "{" + keysAndVals + "}";

void loop(){
  // read raw accel/gyro measurements from device
  CurieIMU.readMotionSensor(ax, ay, az, gx, gy, gz);

  // display JSON formatted accel/gyro x/y/z values
  String keyVals = jsonEncodeValue("ax", ax) + ",";
  keyVals += jsonEncodeValue("ay", ay) + ",";
  keyVals += jsonEncodeValue("az", az) + ",";
  keyVals += jsonEncodeValue("gx", gx) + ",";
  keyVals += jsonEncodeValue("gy", gy) + ",";
  keyVals += jsonEncodeValue("gz", gz);


    axBrightness = ax/66.66;

    ayBrightness = ay/66.66;

    azBrightness = az/66.66;

It says that the 'CurieIMU' does not name a type, but if the #include line of code is removed it is replaced by 'CurieIMU' does not name a type, so I am just confused and slightly lost on what the proper steps are to take in making the code work.

I am a beginner and was wondering how I can avoid and fix this ongoing obstacle I running into, also updated with the code that some people requested.

This is the error message that is displayed if the #include <CurieIMU.h> is inputted.

acclometer:2:22: error: CurieIMU.h: No such file or directory compilation >terminated. exit status 1 CurieIMU.h: No such file or directory

  • What do you mean by does not work? Did your computer explode? Did it give you a headache? Did you get an error message? Did you expect A, but B occurred? Right now, the only way to answer your question is by saying "Investigate the problem and fix it". Please refer to tour before doing anything else. – GMc Jul 26 '19 at 23:46
  • 1
    very simple, do not use the include file – jsotola Jul 27 '19 at 0:35
  • 1
    This is a case study in how not to ask a question ON a Stack Exchange site. You ask a very vague question without providing enough detail for your readers to have any idea what's going on or how to fix it. Imagine a question: "My car is making a funny noise. How do I fix it, and how much is it going to cost?" That's about what you've posted. – Duncan C Jul 27 '19 at 0:51
  • 1
    @amir, people here are keen to help you, unfortunately you have not provided any information to enable them to help you. You have obviously gone to the trouble of creating a profile and having a go at trying to ask a question. Assuming you actually want help, go the extra step and provide some details. Remember there are experts here that can help you, but they cannot read your mind and they cannot see your screen nor your setup. Enable them to help you provide some details. – GMc Jul 27 '19 at 2:45

I think you have two problems.

  1. You are using arduino mega and
  2. You did not read this page Arduini Libraries

It says that the curielMU library is for Arduino 101 only.

I know that when you click into the library it says The Curie IMU library enables an Arduino or Genuino 101 to read the output of the on-board IMU. The key here is that it means Arduino 101 or Genuino 101. It does not mean any random arduino (e.g. mega).

Why? The key is in the second part of the statement which says "enable the onboard IMU". The mega does not have an onboard IMU (as far as I know) so the library doesn't work for it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.