Hello all,
I am new to using the TEENSY platform so excuse me if this is a noob question.
My project requires the use of an accelerometer/gyroscope to get pitch and roll values. My code works on the Arduino nano but it was not able to detect rapid movements of the GY-521 board, hence why I switched to a TEENSY 4.0
I hooked up the VCC of the GY-521 to 5V (I also tried 3.3V), GND to GND, SDA to pin 18, and SCL to pin 19.
I loaded up the code on the teensy and it worked...sort of. Only the pitch and roll values in the positive directions would give accurate data. Whenever I tilted the GY-521 in the opposite directions, the pitch and roll values would blow up to very large values.
To figure out what was wrong, I printed all the necessary information to the serial monitor and what I found was that the raw accelerometer values seemed to be correct, however the raw gyro values along the negative pitch and negative roll axis were obviously false.
For example, when tilting the board towards the positive pitch axis, I would get a reasonable POSITIVE result of around 5 deg/sec. However, when I tilted it towards the negative pitch axis I was reading a POSITIVE result of around 400 deg/sec. Clearly something is wrong with the raw gyro values.
I tried the code again on the arduino and it worked flawlessly. Please help me and thanks in advance !
My code is attached to this post.
View attachment main.cpp
I am new to using the TEENSY platform so excuse me if this is a noob question.
My project requires the use of an accelerometer/gyroscope to get pitch and roll values. My code works on the Arduino nano but it was not able to detect rapid movements of the GY-521 board, hence why I switched to a TEENSY 4.0
I hooked up the VCC of the GY-521 to 5V (I also tried 3.3V), GND to GND, SDA to pin 18, and SCL to pin 19.
I loaded up the code on the teensy and it worked...sort of. Only the pitch and roll values in the positive directions would give accurate data. Whenever I tilted the GY-521 in the opposite directions, the pitch and roll values would blow up to very large values.
To figure out what was wrong, I printed all the necessary information to the serial monitor and what I found was that the raw accelerometer values seemed to be correct, however the raw gyro values along the negative pitch and negative roll axis were obviously false.
For example, when tilting the board towards the positive pitch axis, I would get a reasonable POSITIVE result of around 5 deg/sec. However, when I tilted it towards the negative pitch axis I was reading a POSITIVE result of around 400 deg/sec. Clearly something is wrong with the raw gyro values.
I tried the code again on the arduino and it worked flawlessly. Please help me and thanks in advance !
My code is attached to this post.
View attachment main.cpp