Im trying to take readings from my accelerometer and covert it to an int so i can send it to my servo
If it helps im using an arduino mega
But i get this error
invalid conversion from 'char' to 'const char*'
My code
// Example which uses the MMA_7455 library
// Moritz Kemper, IAD Physical Computing Lab
// moritz.kemper@zhdk.ch
// ZHdK, 03/04/2012
// Released under Creative Commons Licence
#include <Wire.h> //Include the Wire library
#include <MMA_7455.h> //Include the MMA_7455 library
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0;
MMA_7455 mySensor = MMA_7455(); //Make an instance of MMA_7455
char xVal, yVal, zVal; //Variables for the values from the sensor
void setup()
{
myservo.attach(9);
Serial.begin(9600);
// Set the sensitivity you want to use
// 2 = 2g, 4 = 4g, 8 = 8g
mySensor.initSensitivity(2);
// Calibrate the Offset, that values corespond in
// flat position to: xVal = -30, yVal = -20, zVal = +20
// !!!Activate this after having the first values read out!!!
mySensor.calibrateOffset(0.23, 32, -79);
}
void loop()
{
xVal = mySensor.readAxis('x'); //Read out the 'x' Axis
yVal = mySensor.readAxis('y'); //Read out the 'y' Axis
zVal = mySensor.readAxis('z'); //Read out the 'z' Axis
pos = atoi(xVal);
myservo.write(pos);
Serial.print(xVal, DEC);
Serial.print("\t");
Serial.print(yVal, DEC);
Serial.print("\t");
Serial.println(zVal, DEC);
Serial.println("");
delay(150);
}