Arduino and MuRata Gyrostar

Hi Everybody,

My first post detailing my first Arduino project! After quickly getting bored with “blink” I started looking at something else to do with my new Freetronics Eleven Arduino “clone”.

I’ve had a MuRata Gyrostar piezoelectric rate sensor lying around for a few years. I salvaged it out of an old Westinghouse Optus Mobilesat dome antenna.
It’s been a very long time since I’ve done any real programming… I’ve been more involved with hardware and RF. Anyway, the Gyrostar outputs a voltage that changes proportionality to rotation. When it’s at rest the voltage is steady… rotate clockwise and the voltage increases, rotate counter-clockwise and the voltage decreases.

 Intertia Sensor Test Sketch
 Reads an input from MuRata Gyrostar rate sensor on analog Pin0.
 Toggles Red and Green LEDs depending on CW or CCW rotation.
 Prints the results to the serial monitor.
 The circuit:
 * Intertia sensor output connected to analog Pin0.
 * Red LED on Pin7
 * Green LED on Pin8
 created 29 Feb 2012
 modified 01 Mar 2012
 by Michael VK5ZEA

// Constants

const int analogInPin = A0;  // Analog input pin that the rate sensor is attached to
const int red = 7; // Red LED
const int green = 8; // Green LED

int sensorValue = 0;        // value read from the rate sensor
int RateCentre = 351;
int RateSpan = 20;

void setup() {
  // initialize serial communications at 9600 bps:
  pinMode (7, OUTPUT);
  pinMode (8, OUTPUT);

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);            
  if (sensorValue < (RateCentre+RateSpan) && (sensorValue > (RateCentre-RateSpan))) {
    digitalWrite (red, LOW);
    digitalWrite (green, LOW);
  if (sensorValue > (RateCentre+RateSpan)) {
    digitalWrite (red, HIGH);
    digitalWrite (green, LOW);
  if (sensorValue < (RateCentre-RateSpan)) {
    digitalWrite (green, HIGH);
    digitalWrite (red, LOW);
  // print the results to the serial monitor (diagnostics):
  Serial.print("Gyrostar = " );                       
  // wait 100 milliseconds before the next loop

I’d eventually like to use the Gyrostar on a wheeled robot to detect when it’s not going in a straight line and then apply correction to the speed of one of the motors to bring everything back into line.

So far I’m having lots of fun.


Great video! I know gyro sensors but I didn’t know they can be this sensitive to slight rotation. BTW, I have a commodore but I bought it a year ago to add to my collection of vintage computing :wink: The age of commodore was with programming and interfacing and now the age of arduino brings that all back and in a whole different level.