Weekend Project – Over-engineered level

This little project is from a while back, but I thought I would share it anyways.

The idea:
I can’t go into too many technical details, as some of them are classified.
During one of my previous projects I had developed an IMU (Inertial Measurement Unit). I though about what else could be done with this finished PCB and came up with the idea to use it as a level. Now, levels are usually these really low-tech things and I thought it would be fun to completely over-engineer it. Plus I actually needed a level as I was moving at the time and had some things that I needed to hang. 🙂

How it works:
Like I said I basically had a finished IMU lying around and so I decided to just use the accelerometer in it to measure if the PCB of the IMU is perpendicular to the earth’s gravitational field. If it is, then all of the G-force is measured in the Z-axis of the accelerometer. So the more acceleration is measured in the X and Y-axis the less level everything is. As an output I decided to just use some LEDs and through PWM adjust the brightness according to the acceleration measured in X and Y. I included a little threshold, in which the LEDs are completely off as a “close-enough” indicator. The PWM is generated manually with one of the Timers, since the MCU used had no available PWM outputs.

Everything is powered by a coin cell (3V). This is really stretching the minimal operational voltage (2,7V) of the MCU as the battery voltage drops when the capacity gets lower. Especially during power-up the voltage across the battery dropped significantly. I solved this by simply putting capacitor in parallel to the battery supporting it during power-up.

The hard part:
Since I already had the PCB and most of the code the hardest part probably was soldering the tiny wires to the existing PCB. I basically had to use the pads, that were meant for the MCU and attach tiny wires to that. I then put some drops of hot glue to keep everything in place.
This made for a nice little device that can be used as a level. It even tells you if things are level in both X and Y-axis at the same time. It’s also quite fun to play arround with. Shaking it back and forth and tilting it around kind of gives you the feeling of bouncing around a little red ball.

Below is a video showing everything in action. I compared it to a “normal” level and it actually performs pretty well. But what else would you expect when you are measuring gravitation. Of course its going to be completely vertical. The biggest error probably comes from the two PCBs not being completely parallel to one another.

Weekend Project – LEDs as Sensors

So I have been wanting to try this out for a while now and I finally got around to doing it this weekend.

The Theory:
Due to the semiconductor properties of LEDs they are capable of detecting light in the same or close to the wavelength they would normally emit. This allows you to use LEDs as a light sensor. Using an Arduino Mega and its analog input pins I was able to make this little circuit which exploits this property. The voltage that is produced is quite small so the accuracy and resolution is not very hight, but it does work quite well.

What it does:
I then hooked up another lead of my RGB-LEDs to a pwm output and made the LED light up according to how much light it is sensing. This allows for some interaction with the circuit instead of just looking at numbers on the screen.

Keep in mind, this was just a quick weekend project, so the code and the circuit are not very elegant or anything.

How the code works:

  • Configure all analog inputs to outputs and pull low to turn on all red LEDs.
  • Turn one analog input pin into an actual Input and read the amount of light that is reflected into it.
  • Turn that input back into an output and continue on to next.
  • After all inputs have been read adjust the PWM of the blue LEDs according to the amount of light that was measured.
  • loop forever…

Here is a short clip demonstrating how it works. Please excuse the flickering. This is due to the LEDs being switched on and off constantly and that interfering with the exposure time of the camera. Also I didn’t realize one of the LEDs wasnt working: