Arduino and FRC Sensors

Well, on my grand Arduino goals I am going to try to use the various FRC sensors such as the Accelerometer, Gyro, and the Rotary/Linear Magnetic Encoders.

My 2 biggest goals are the Accel and Gyro but I my team has never used these before and so I am going to start by getting it to work with the Arduino (hopefully easier, and I don’t have the cRIO over break).

I noticed that the Accel is the same 1 as on SparksFun except the board connectors are different and the documents provided by FIRST seem quite complex. So step 1 would be figuring out how to set it up and then program it.

Anyone have some advice to start the code or can mention the proper way to connect it to the arduino.


First, you have to figure out how it communicates with the microcontroller - usually i2c, analog, or SPI. If it’s i2c, you’ll need to find out its address. From there, google “arduino i2c accelerometer” (or whatever) and you’ll have lots of information.

Or, if it’s a pretty common sensor, you can just google the name of it with “arduino” tacked on to the front and get a good guide.

Any way you do it, you’ll end up with raw data, which will need filtering and math to get useful information.

A gyro measures yaw rate, so it outputs a velocity. If you integrate it once, you will get angular heading. If it’s analog, you’ll also need a center bias, usually digital ones output a signed number. Don’t worry about the calculus, it’s fairly easy to “cheat” in robotics programming.

An accelerometer measures acceleration, so you’ll need to integrate it once to get velocity and twice to get distance (at which point it’s very inaccurate). If you aren’t moving at all, you can use it as an inclinometer by finding the vector G from multiple axis of acceleration perpendicular to each other. Like the analog gyro, analog accelerometers need a center bias.

If you want vehicle speed and/or position, a pair of quadrature encoders and a gyro is the way to go. Although there can be wheel slip in the encoders, they’re generally more accurate than the second integration of acceleration (which itself could be a noisy analog signal).

If you want to run quadrature encoders, you’ll need to setup an ISR on one or both of the pins, on one or both edges (the number of interrupts = the decoding, one edge of one pin = 1x, both edges of one pin = 2x, both edges of both pins = 4x) and check the other pin to get direction. Speed comes from the first derivative of distance or the time between samples (I recommend filtering it any way you do it, it will be fairly noisy).

Alright, so for the Accel, 1 tutorial mentions to use SDA and SCL and connect them to pin 4 and 5 on the Arduino, but the board layout is different. So this might sound a little stupid but how do I connect the power for this board, I only see the the 2 0V and 5V connectors and I don’t see anything else relating to Ground.

Gnd/Ground is 0v (at least in DC circuits), so connect the 5V to the 5V pin on the arduino and the 0v to one of the Gnd pins.