Introduction: Grove Single Axis Analog Gyro

This is the second tutorial of the series where I work with a Grove senor or components and an Arduino. In the last tutorial I showed you how to wire up a Grove I2C motor driver with an Arduino, make sure read through that also.

In this tutorial I'm going to show you how to get stared with a Grove single axis analog Gyro and an Arduino. This tutorial will serve as a basic if you are going to make a self balancing robot or an orientation sensor.

So lets get started.....

Step 1: Tools and Components

All you need to get started is -

  • Arduino UNO
  • Grove single axis analog Gyro
  • Jumper wires

Note- No soldering skills are required to build this project, but it is good to know how to solder there are a good soldering tutorials on YouTube that can help you get started.

Step 2: Hardware

Time to connect the Arduino to the Grove analog Gyro, the connections goes as follows -

  • Arduino +5V - Grove analog Gyro VCC
  • Arduino Gnd - Grove analog gyro Gnd
  • Arduino analog pin 0 - Grove analog Gyro SIG

Note- The NC pins stands for no connection and as the name suggests there is no connection to this pin and the pin is maintained just as a grove standard four pin connector.

Step 3: Code

After getting the hardware connected its now time to upload the program, feel free to modify the code and make it suitable for your project.

All that the code does is reads the analog value and does some mathematics and prints it out on a serial monitor. The processed data can be used to make an orientation sensor which I will show soon.

<p>int sensorPin = A0;             // select the input pin for the sensor<br>
float reference_Value=0;</p><p>int sensorValue = 0;            // variable to store the value coming from the sensor</p><p>void setup() {</p><p>    int i;
    float sum=0;
    pinMode(sensorPin, INPUT);
    Serial.println("Please do not rotate it before calibrate!");
    Serial.println("Get the reference value:");
        // read the value from the sensor:
        sensorValue = analogRead(sensorPin);
        sum += sensorValue;
    reference_Value = sum/1000.0;
    Serial.println("Now you can begin your test!");
}</p><p>void loop() 
{</p><p>    double angularVelocity;
    sensorValue = analogRead(sensorPin);
    angularVelocity =((double)(sensorValue-reference_Value)*4930.0)/1023.0/0.67; //get the angular velocity
    Serial.println(" ");