Introduction: Hall (effect) Log Lamp

A couple of years ago we decided to have a winter holiday in Scotland. We just wanted to get away for a little while and possibly find some snow. Unusually for the time of year our days where fill with sunshine and blue skys.

We purchased some logs for the wood burner but didn't use all of it so we decided to bring home what we had left. This one log was placed by the fire at home and for some reason we could never bring ourselves to burn it. The weeks turned into months then we moved home and the log from Scotland came with us.

I decided some months ago that it should become a lamp otherwise it would just sit by the door forever gathering dust. The original plan was somthing simple with a base and and top but as is often the case once the project started the design evolved quickly into somthing a bit more dynamic.

The brightness of the lamp changes depending on how open it is. When its closed the LED is off. The wider open it is the brighter it is.

The effect is achieved by using a magnet and a hall effect sensor the output of which is fed into a micro controller that drives a PWM input on a 350 LED driver board. The whole system runs on 5 volts and draws less than half an amp at full brightness.

Parts List:

  • ATTiny 85 Micro controller (plus your preferred system to program it)
  • Arduino Uno for calibrating
  • Minature ratiometric hall effect sensor (SS495A)
  • 350ma LED Driver DC-DC (ebay search for: 350ma dc led driver pwm)
  • 1w warm white LED on star PBC
  • Heat sink for the LED
  • Selection of wires
  • USB cable
  • Hinge
  • DIP 8 IC socket (optional)
  • Prototyping board (optional)


  • axe
  • power sander
  • router
  • saw
  • hole drilling bit
  • power drill
  • chisel & hammer
  • soldering iron

Why I chose these parts

I choose the ATTiny 85 as the micro controller due to its size and low power usage, it also has more than enough IO pins for this project. It can be programmed with the Arduino IDE and its just so cute!

The SS495A might have been the wrong choice for this as its bipolar and so possibly has a more limited range of output when used in this way to what a unipolar might. However when I was researching hall effect sensors I found a video that demonstrated this one doing what I needed it to do, its also very small and cheep.

The LED driver I already had but what I still like about this type is thats its a step down driver and only needs about 1v over the forward voltage of the LED to work. As we are supplying 5v and the LED only needs 3.4v it perfect. Its also small has PWM dimming and again is cheep.

The LED really is personal preference. 1W is plenty bright enough to give a nice background light to a small room or hall way. They don't generate too much heat and come in a wide range of colours. You could just buy the LED with out the star PCB but it makes them much easier to attach to a heat sink.

The heat sink I have used for the lamp might be a little bit of over kill for a 1w LED however as its fitted into wood (not a good conductor of heat) I though it best to go too big than too small and have the LED burn its self out.

Step 1: Splitting, Sawing, Sanding, Routing, Drilling

As this is a unique piece of wood I think it was be best to tell you how I worked it to achieve the end result and will move onto a more conventional Instructable style once things become more repeatable.

As the log had dried out a natural line opened up so it was the obvious place to split it using an old axe and piece of wood drive the axe in. the log came apart relatively easily and the bark mostly just fell off.

I used a hand saw to cut down the length of one of the pieces to create a flat bottom then spent a couple of hours sanding with the belt sander to get everything tidy, flat and smooth.

The router came out next and I routed out a recess in the bottom of the bottom piece for the electronics. I then routed a channel in the top piece to accommodate the support arm.

I made the support arm from the off cut by splitting it and sanding it into a round stick(for want of a better word)

I marked the location of the hinge, the magnet and hall effect sensor with a pencil and used a chisel to cut the recess for all of them. The magnet need to be very close the the Hall effect sensor when the lamp is closed and not more then about 75mm away when open ( I will go into more detail later about the sensor and magnet)

Using the adjustable hole cutter on the power drill I bored out a space for the LED heat sink to fit into then drilled a hole diagonally into the channel for the wires to run. I also drilled 2 holes through the back into the bottom recess for the power in and LED out and one hole in the top piece that lined up with the channel for the support for the LED power wires.

Working out where to place the steps for the supporting arm to sit into was a case of cutting out a little bit at a time with the Dremel and testing to find the right height for each step.

Then stick the magnet on place with a drop of glue.

Step 2: Setting Up the Sensor

The SS495A Hall effect sensor is pretty easy to get working. Solder a wire onto each of the legs and use a little heat shrink to insulate them from each other then push the wires down into the hole and out through the bottom until the sensor sits flush.

Connect the 5V leg to the 5V pin on the Arduino UNO, Ground to Ground and the output to Analog Pin 0

Upload the AnalogInOutSerial Sketch from the Analog menu in the examples menu onto the Arduino Uno and open the serial monitor on your computer.

As you open and close the lamp the sensor the values will change. For this project we are only interested in the sensor values as we will create custom brightness levels for the lamp based on these values.

Fully closed the output on my lamp was 0 as it was opened the value went up to just over 500. Make a note of numbers at the various levels.

I said in the introduction that my choice of sensor may not have been the best as this is a bipolar sensor meaning that one pole of the magnet will give a reading of 0 - 500 and the other from 500 to 1000, I think A unipolar would have given a reading from 0 to 1000 making it a better choice for this project.

I had a bit of trouble with the last 2 setting on my lamp as the difference between mostly open and fully open was quite small. In the end I lowered the height of mostly open to create a bigger difference between the two.

Our final sketch also uses some soothing to average out the readings, this helps to avoid any jumps from slight fluctuations in the sensor output.

Step 3: Setting Up the LED and Driver

I really like these driver boards. I have one thats been running in another lamp without any problems for a few months, so in my experience they are cheep, reliable and work great.

The LED used here is a 1W or 350ma warm white LED. It came pre-mounted to the aluminium PCB, again this type of LED is cheep, reliable and plenty bright enough for a small lamp. The one downside is that the light emitted creates harsh shadows. This could be fixed with some type of diffuser but I quite like the strong lines of light and dark it creates.

It is possible to solder onto the LED pads but my little 25w iron wasn't up to the task. Fortunately I have a older and bigger iron that was able to get enough heat into it for a good joint. I have seen on youtube that placing the LED onto an cloths iron set at about 100 degrees centigrade will make soldering a lot easier.

Be sure to solder the wires onto the LED before attaching it to the main heatsink with a little thermal compound and the screws provided.

Run the wires from the LED through the hole, along the channel and out the back of the lamp. I used some para cord with the insides removed to create a sleeve for the wires before pushing them into the bottom half of the lamp and securing them in place with hot glue.

Push the LED and Heat sink assembly into the hole created and fix in place with hot glue

The wires can be cut to lengths and soldered onto the OUTPUT terminals of the LED driver.

Step 4: Wiring It All Up

I had a off cut of prototyping board kicking about so I decided to use it to keep everything tidy but you can just as easily solder everything together without it.

For the main power in cable I used an old USB cable. Once stripped you will normally find 4 wires. There is a good chance that the RED will be 5V and the black Ground but its always worth double checking with a multi meter especially as there is a capacitor on the LED driver board that might explode if the polarity is reversed. Once you are happy you know which ones you need poke it through the hole in the back and cut the other two at different lengths so they can't short out. Seal it up with a bit of heat shrink and hot glue it in place.

Use a IC holder for the ATtiny 85. this will allow it to be removed if it needs calibrating again with the sensor.

5v need to get to:

Pin 1 of the Hall effect sensor

Pin 8 of the ATtiny 85

Vin+ on the LED driver board

I have also added a 470UF capacitor between 5v and ground. I don't think its really needed but will help protect the micro processor from power spikes.

Ground to:

Pin 2 of the Hall effect sensor

Pin 4 of the ATtiny 85

Vin- on the LED driver board

As all the grounds are shared there is no need to have a connection to PWM- on the LED driver board but this may not be the case with all drivers.

Step 5: Program the ATtiny 85

I use my Arduino Uno to program my ATtiny but other methods exist so please use what ever your most comfortable with. my method is the same as this:

The code is straight forward. Its just a modified version of the smoothing example found in the Arduino IDE. The main loop reads the sensor 20 times and takes an average of the reading that gets passed to a set of if / else if statements. When it finds one that matches it sets the brightness on pin 0 with PWM.

The LED driver board is designed to work with and without dimming, as a result you have to pull the PWM pad LOW to turn the LED on.

So when the lamp is closed. The sensor reads 0 and the micro processor set the PWM at 100% turning the LED OFF.

Here is the if / else if statements.

if (average <=200 ) {
analogWrite(pwmPin, 255);} //Off else if (average >200 && average <=370) { analogWrite(pwmPin, 220);} // DIM else if (average > 370 && average <=470) { analogWrite(pwmPin, 150);} // Medium DIM

else if (average > 470 && average <=490) { analogWrite(pwmPin, 100);} // Just A bit DIM

else if (average >=490) { analogWrite(pwmPin, 0);} //FULL Brightnes

You can download the full code and edit the average values to match the ones you took when setting up the sensor. Upload it to the ATtiny. Plug the ATtiny into the IC socket on the lamp and you should be all set.

Enjoy your lamp!

Creative Misuse Contest

Participated in the
Creative Misuse Contest