Introduction: "Arduino Micro" Camera Tower Level

About: My name is Kevin Palivec. I'm a network engineer who lives in Texas. I love building useful stuff from scavenged parts.
I have a camera up on a pole that I use for video meteor hunting. One problem I've had is making sure the tower is level at the top. It has to be really level to make sure the entire horizon is visible to the fisheye lens on the camera.
I've seen various little leveling tools for the towers but none were easy to use. I thought I could make one more suited to my needs!

Also after high wind and storms. Sometimes the tower would get un-level and I'd have to bring it down and reattach my leveling equipment. What I needed was a  solution that could be set up on the top of the tower in the camera housing that I could see from the ground as I did the towers leveling.

I had an Arduino Micro that I'd been playing with and some sensors from a Parallax BoeBot kit. in it I had a compass and a tilt sensor.
I decided to see if I could build a simple electronic bubble level to keep on the tower and view from the ground when I needed to level the camera.
In my application I run the power lines down to the tower bottom and just hook up a battery when I need to use the level.

In this instructable I'd like to show you how to set up a simple arduino based "leveling bubble"

Step 1: Parts Needed

The parts you'll need for this project are:

1. An Arduino Micro

2. an  2125 Accelerometer

3. a Small breadboard

4. Several length's of wire.

5. 4 Red LEDs and One Green LED

Step 2: A Little Theory of Operation.

A little background about how the tilt sensor works!

Inside the little box on the sensor is a tiny heat source. on each side are small thermal sensors that can detect the heat generated by the middle of the block. as the sensor is tilted. This heat rises towards one of the sensors and by comparing the values the device can sense at which angle it's being tilted.
The Arduino reads this data and converts it into an X Y measurement that can be used to light up LEDs to indicate the tilt direction.

Step 3: Hooking It All Up!

Place the Arduino Micro onto the breadboard and make sure to leave some room for your sensor and LEDs.
You could break out the LEDs to a separate "display" board if needed.

Connect the m2125 to the Arduino Micro in the following way.

Digital Pin 2 ----- M2125 pin 5        (white wire)
Digital Pin 3 ----- M2125 pin 2        (orange wire)
Ground to    ----- M2125 pins 3 4   (all ground wires are black)
5volts to      ------ M2125 pin 6       (Red wires)

Center (green led)           to pin D5       (blue wire on diagram)
lower X (left red led)        to pin D8       (purple wire on diagram)
upper X (right red led)     to pin D7       (brown wire on diagram)
upper Y (top red led)       to pin D6       (yellow wire on diagram)
Lower Y (bottom red led) to pin D13    (green wire on diagram)
See diagram

Step 4: Tell the Ardunio How to Monitor the Sensor

Now we need to upload a sketch into the arduino so it'll be able to monitor the output from our sensor and tell usis it's all on the level!
This sketch, besides lighting up the LEDS will also output the X Y measurements to serial if you'd like to monitor the data
The stream feeds out in this format:   X(xvalue)Y(Yvalue)
IE. X243Y165

each line ends with a carrage return.

________________________________________________


//arduino micro led visual level

const int X = 2; //X pin on m2125
const int Y = 3; //Y pin on m2125

void setup() {
  //set up serial
  Serial.begin(9600);
  //set the pins to output for leds
  for (int i=5; i < 13; i++){
  pinMode(i,OUTPUT);
  }
  pinMode(X, INPUT);
  pinMode(Y, INPUT);
}

void loop() {


//read in the pulse data
  int pulseX, pulseY;

  int accelerationX, accelerationY;

  pulseX = pulseIn(X,HIGH); 
  pulseY = pulseIn(Y,HIGH);

   //map the data to between 0 and 500
  accelerationX = map(pulseX, 3740, 6286, 0, 500);
  accelerationY = map(pulseY, 3740, 6370, 0, 500);
  if (accelerationX > 249 and accelerationX < 259 and accelerationY >249 and accelerationY < 259){
      digitalWrite(5,30);
      }
  else {
    digitalWrite(5,0);
       }
  if (accelerationX < 249) {
      digitalWrite(8,30);
      }
      else {digitalWrite(8,0);
      }
      if (accelerationX >261) {
      digitalWrite(7,30);
      }
      else {digitalWrite(7,0);
      }
       if (accelerationY < 249) {
      digitalWrite(13,30);
      }
      else {digitalWrite(13,0);
      }
       if (accelerationY >261) {
      digitalWrite(6,30);
      }
      else {digitalWrite(6,0);
      }

  //Send the data to the serial in case we'd like to see what's being reported and possible pc use later
  Serial.print("X");
  Serial.print(accelerationX);
  Serial.print("Y");
  Serial.print(accelerationY);
  Serial.println("");



  // delay the data feed to we dont overrun the serial
  delay(90);
}

Microcontroller Contest

Participated in the
Microcontroller Contest

Arduino Contest

Participated in the
Arduino Contest