Hi
I am new to the world of Arduino.
I have recently bought a Arduino Mega 2560 and a Gyroscopic sensor with accelerometer, but can’t get it to work correctly.
I did some research on the net to find code with some potential, Here is what I got…
int gyroPin = 0;
float gyroVoltage = 5;
float gyroZeroVoltage = 2.5;
float gyroSensitivity = .007;
float rotationThreshold = 1;
float currentAngle = 0;
void setup() {
Serial.begin (9600);
}
void loop() {
float gyroRate = (analogRead(gyroPin) * gyroVoltage) / 1023;
gyroRate -= gyroZeroVoltage;
gyroRate /= gyroSensitivity;
if (gyroRate >= rotationThreshold || gyroRate <= -rotationThreshold) {
gyroRate /= 100;
currentAngle += gyroRate;
}
if (currentAngle < 0)
currentAngle += 360;
else if (currentAngle > 359)
currentAngle -= 360;
Serial.println(currentAngle);
delay(1000);
}
Any help would be much appreciated!
Thanx in advance
Gidion
moderator update: -added code tags == #button above smileys