Magnetic Tip-over Sensor

Schematic:

Construction:

  1. This circuit must be built in two separate sections to prevent the magnet from swinging only toward the capacitor and not hang down. Fit as much of the circuit as you can on a small 1/2" x 1 1/8" piece of circuit board. The sensor (A3121) must be mounted in the center of a 1 1/8" square circuit board, make sure that its marked face faces upward. You may need to place some of the diodes on the square board if they won't fit on the small board. Use a few inches of ribbon cable to connect the two circuits, but only solder one end of the cable at this time.
  2. On a 2 x 4 Lego brick, cut a notch large enough for the ribbon cable toward the top of one short side. Drill out the two pins on the opposite side. Remove all of the insides.
  3. Insert the on cable through the notch and finish soldering.
  4. Solder two very short 3/16 rods (must be about 1/8" long) to wires that connect to the circuit where it is labeled "RCX".
  5. Insert the rods into the holes in the brick to replace the pins and glue them in place with super glue of epoxy.
  6. Place the circuit board in the block and glue a flat Lego plate over the bottom. You may need to cut all of the pins off the plate.
  7. Cut the top and halfway down one long side on two more bricks so that the square board will sit inside them. Cut a notch for the ribbon cable.
  8. Cut the top and the entire side off of two more blocks.
  9. Cut of the sides and the insides of two more blocks. On one block, leave a small piece in the center of the side and drill a small hole in it.
  10. Glue the two blocks you made in step 7 together and set the board inside them.
  11. Glue the next two blocks on top of them, and then glue the top brick with the hole in it on top of those.
  12. Glue a string to the south side of a tiny magnet. Once the glue is dry feed the other end of the string through the hole in the top brick. Adjust the string until the magnet is on top of the sensor and so it is just high enough to swing freely. Glue the string to the hole.
  13. Glue the last block in place to enclose the sensor and swinging magnet.

Implementing this sensor:

The RCX must be told that this sensor is a light sensor. When the sensor is upright it will read about 88 but if the sensor tips it will read 0. When programming, be sure to put a delay to account for possible swinging. For example, if there is no delay and the sensor is in a car then every time it starts the magnet will swing making it think it has tipped over. To compensate write in a delay and watch for the number to go back up, if it does the magnet is just swinging, if there is nothing after a few second it has tipped over.

The sensor:

The A3121 is a Hall-Effect Switch make by Allegro Microsystems. Basically all that it does is turn on in the presence of a northern magnetic field and turn off when there is none.