tomy
1
this year we are finally going to use the gyro and accelometer, both of them are hocked up right but neither of them are working.
the gyro is hooked up to crio module 1 slot 1
and the accelometer is hooked up to the I2C port.
we tried to program them but neither are working
anyone got some example code
p.s. sorry if there is another post about this i running late for a meeting and needed to post it quickly before i forgot
Could you please post the source code you are trying?
tomy
3
I don’t have the computer now but for the gyro we did
gyro.reset
gyro.get angle()
Is there anything special you have to do to see it the driver station?
That code is incorrect,
gyro.Reset();
gyro.GetAngle();
tomy
5
Like I said I dont have the computer…
DriverStationLCD *display = DriverStationLCD::GetInstance();
char text[255];
sprintf(text, "Gyro Value: %f", gyro.GetAngle());
display->Clear();
display->PrintfLine(DriverStationLCD::kUser_Line1, text);
display->UpdateLCD();
Or if you mean the display on the Dashboard, take a look at the DashboardData sender in some of the example projects (such as Vision tracking).
Only call Reset() when you want to reset the gyro to its initial state. If you do it every time you try to read GetAngle(), you will always read zero.
tomy
8
Thanks ala
Will it automatically show up on the driver station (the compus thingie)
That’s the dashboard, and no it won’t. Take a look at the example project DashboardDataExample.
tomy
10
what about the accelometer we have it pluged into the I2C Port in our programing i think we did something like this
acc.(I2C);
and it did not work
That shouldn’t have compiled, here are the available functions for the ADXL345 accelerometer: http://mmrambotics.ca/wpilib/class_a_d_x_l345___i2_c.html
You are initializing these objects too correct? Please post full source code when you can, it will be much easier for us to help you.
tomy
12
tommarow around 4 central time i will post my code here