Hi i'am trying connect this gyro with arduino and not mutch luck =(
Pls has anybody sample code how to get data from gyro?
What have you got, and what doesn't it do that you want it to?
(or, what does it do that you don't want it to?)
What experience have you got with gyros?
int x = analogRead (X_AXIS) - x_null;
Where "x_null" is the average stationary reading.
If you leave it at zero, it'll just return the raw value from the device.
Hi i've got zero experience with gyro but i can undestand teory of mems gyroskopes;-)
this is my arduino code:
int x,y;
float cas, hodnota_x, hodnota_y;
void setup(){
Serial.begin(9600);
}
void loop(){
x = analogRead(2);
y = analogRead(3);
cas = millis();
//hodnota_x = (x/1.0323)*cas/1000;
//hodnota_y = (y/1.0323)*cas/1000;
Serial.print("osa x = ");
Serial.print(x);
Serial.print(" ");
Serial.print("osa y = ");
Serial.println(y);
delay(500);
}
i think i connected the gyro with arduino corectly.
i get data from sezor but i need convert it to degrees per seconds °/s can you know how i make it???
The data sheet will specify the sensitivity of the device in millivolts per degree (or radians) per second.
You know what voltage you're reading, so just do the arithmetic.
AWOL:
The data sheet will specify the sensitivity of the device in millivolts per degree (or radians) per second.
You know what voltage you're reading, so just do the arithmetic.
can you write me aritmethic equation ? i don't know how
lorduriel:
AWOL:
The data sheet will specify the sensitivity of the device in millivolts per degree (or radians) per second.
You know what voltage you're reading, so just do the arithmetic.can you write me aritmethic equation ? i don't know how
here is my code:
#include <Wire.h> //knihovna I2C
#include <math.h> //knihovna Math
unsigned long casovac=0;
unsigned long cas=0;
//kalibrace
long resultGyroX;//x-axis
long resultGyroY;//y-axis
//
//gyros
float gyroZeroX;//x-axis
int gyroXadc;
float gyroXrate;
float gyroXangle;
float gyroZeroY;//y-axis
int gyroYadc;
float gyroYrate;
float gyroYangle;
void setup(){
Serial.begin(9600);
gyroZeroX = calibrateGyroX();
gyroZeroY = calibrateGyroY();
delay(100);
}
void loop(){
cas = millis();
gyroXadc = analogRead(2);
gyroYadc = analogRead(3);
gyroXrate = (gyroXadc-gyroZeroX)/1.0323;//(gyroXadc-gryoZeroX)/Sensitivity - in quids Sensitivity = 0.00333/3.31023=1.0323
gyroXangle += gyroXratecas/1000;//Without any filter
gyroYrate = (gyroYadc-gyroZeroY)/1.0323;//(gyroYadc-gryoZeroX)/Sensitivity - in quids Sensitivity = 0.00333/3.31023=1.0323
gyroYangle += gyroYratecas/1000;//Without any filter
cas = millis() - casovac;
casovac = millis();
Serial.print("cas = ");
Serial.print(casovac);
Serial.print("; osa x = ");
Serial.print(gyroXangle);
Serial.print(" ; ");
Serial.print("osa y = ");
Serial.println(gyroYangle);
gyroXangle = 0;
gyroYangle = 0;
}
int calibrateGyroX()
{
for(int i=0;i<100;i++)
{
resultGyroX += analogRead(2);
delay(1);
}
resultGyroX = resultGyroX/100;
return resultGyroX;
}
int calibrateGyroY()
{
for(int i=0;i<100;i++)
{
resultGyroY += analogRead(3);
delay(1);
}
resultGyroY = resultGyroY/100;
return resultGyroY;
}