SparkFun Forums 

Where electronics enthusiasts find answers.

Questions &/or issues related to products in the Programmers category & general programming devices should be posted in this forum.
User avatar
By ProStreet
#208580
I'm using the SparkFun ADXL345 on a Arduino UNO board.
I'm attempting to run a 1 axis self leveling platform.
When I run the Arduino software to compile, I get a error message,
"'SparkFun_ADXL345_Unified' does not name type"
I believe I have all the correct library's installed, but not 100% positive.
I'm VERY new to this.
Any and all comments or recommendations would greatly be appreciated.
Thank You
Jerome
By paulvha
#208587
would help if you have a link to the software or share the code of the sketch. looks to me you try to create a constructor. It should be something like: ADXL345 accel = ADXL345(10).
So leave out SparkFun_ . Also the 12345 is the chip select pin for SPI communication and I am sure this is not a right number. Look at the examples that have been provided with the library to start
User avatar
By ProStreet
#208594
Will attempt to understand you welcome comment. But again I know nothing about this coding.
Enclosed is the entire code to see if this helps.
Thank You
Jerome
/*
* Accelerator demo
*
*/
#include <Servo.h>
#include <SparkFun_ADXL345.h>
// Create servo objects for x and y servos
Servo xServo;
// Used to level the platform, if needed
int xOffset = -7;
// int sensitivity = 50; ORIGIONAL CODE, Changed to below. Works better.
int sensitivity = 0;
// Assign a unique ID to this sensor at the same time
SparkFun_ADXL345_Unified accel = SparkFun_ADXL345_Unified(12345); // THIS IS THE ERROR LINE
void setup() {
Serial.begin(9600);
// Initialize sensor
if(!accel.begin())
{
// Sensor not detected
Serial.println("No Sensor detected");
while(1);
}
// Connect servos to pins
xServo.attach(9);
// Setup sensor Range and datarate
accel.setRange(ADXL345_RANGE_16_G);
accel.setDataRate(ADXL345_DATARATE_25_HZ);
}
void loop() {
sensors_event_t event;
accel.getEvent(&event);
// Get x and y values from sensor
int x = event.acceleration.x;
// map sensor value (-10 - 10) to servo position value (30 - 150)
int x1 = map(x, -10, 10, 130, 50);
// Troubleshoot info - show sensor reading and mapping
Serial.print("X: "); Serial.print(x);
Serial.print("\tX1: "); Serial.print(x1);
// move servos based on sensor mapping
xServo.write(x1 + xOffset);
delay(sensitivity); //delay to decrease sensitivity
}
By paulvha
#208597
Take a look at the examples that are provided with the library. That is the best way to start if you do not know enough (yet). I really appreciate your effort to get going and that your have to start somewhere, as we all did. Start with something that works and take it from there.