Minecraft Server Display

A while ago, I set up a Minecraft server here in our house, so my oldest son could play Minecraft together with his friends. They love doing that, but without turning on the computer, there was no way of knowing if anyone else was on the server. Hence, this project! The idea is that this display will sit on the wall so my son can see immediately if any of his friends are playing Minecraft.

The Minecraft Server Display

The Minecraft Server Display

The display has two purposes, one is to show how many friends are currently online playing on our Minecraft server, the other to show the current time.

At the top of the display, there is an LED which is green if it has contact with the server, otherwise it is red (server is down, connection is bad, etc.). Below the LED is a 7-segment display showing the number of online players (1-9). If no one is online, the display goes blank – that makes it easy to see if anyone is online or not, even if you’re at the other side of the room.

At the bottom there is a display showing the current time. With a press of the yellow button the display will show year, month & day, and day of week (displayed as “d1″…”d7”, where d1 means Monday, d2 Tuesday and so on, since this is Europe, not the US 🙂 ). If the button is held down for a couple of seconds, the display will show its IP-address. This is good for troubleshooting the network, even though I’ve never had a problem.

On the side of the enclosure I put an on-off switch which turns the Minecraft part of the display on and off. Sometimes I think it might be a good idea not to show if anyone is online – if you’re doing
your homework at the computer, for instance.

The red button is a special feature! When pushed, there will be rain, thunder and lightning for thirty seconds. On the Minecraft server, that is. Not in real life.

On the inside

On the inside there is an Arduino Ethernet. A shift register controls the single-digit 7-segment at the top, and the bottom (time) display is a serial 7-segment display.

Technical information

Every thirty seconds or so, the Arduino makes an http-get request to a (secret) webpage on my website. The webpage uses a webservice which I installed on a server I have set up in my house. The webservice, in turn, gets information from the minecraft server using a UDP-protocol (which is not official I guess, but quite well documented here, for instance). That page returns only the number of current online players. Nothing else. Just the number. That information is easily interpreted by the Arduino and displayed on the 7-segment display. If there are more than 9 players online, the 7-segment display will show 9 and a period (my way of displaying more than nine).

The time comes from an Internet Time Server (NTS) and is updated every couple of days, so I didn’t use a clock-module in this build. The time is automatically adjusted for my time zone (Sweden) and also automatically adjusts for daylight savings time (DST). It turns out, that was not as difficult as I initially thought it would be. All I needed to do was to add a little function that answers the question “is-it-DST-now?”. All that function needs to know is current month, date and day-of-week. And I already have that information from the time-library in the Arduino. So this thing always has the correct time!

Making it rain

This is done by making an http-get request to another (secret) webpage on my website. The page sends a command to the webservice which creates a file on the home server. I use a separate piece of software to check if such a file exists, and if it does it sends a command using the remote control function of the Minecraft server (“weather thunder 30”). I really love this function! To me it’s really cool to press a physical button on one device and by doing so having an impact on a virtual world. Awesomeness.

Enclosure

I used a simple black plastic project box here, made some holes for the LED, push buttons, the 7-segment display, the four-digit display and the on-off switch. And holes for Ethernet cable and power.

Fun with EL-wire

Last night was the last day of 2013. So I figured I should do something new to celebrate the new year.

EL-wire

EL-wire

Hence, some EL-wire fun. EL-wire, or Electroluminescent Wire, is a lot of fun to use. It looks really cool and is very flexible and easy to use. But it cannot be lighted with batteries or a wall-wart adapter, so you have to use an inverter.

I took an EL-wire and passed it through some transparent plastic tubes I had laying around to make the numbers 1 and 4. The EL-wire doesn’t light up very brightly, so I let it pass through each section twice, see figure below.

Transparent tubes

The EL-wire runs through transparent tubes

It was very simple to hook up the wire to the EL-inverter, and the EL-inverter to two 1,5V AA batteries. The EL-inverter converts those 3 Volts to an impressive 114 Volts for the EL-wire. This was with almost fresh batteries.

114 Volts

EL-wire uses 114 Volts

The current was about 69 mA, which is a little more than the current of three LEDs. With the fresh batteries. Not bad.

69 mA

EL-wire uses 69mA

Anyway, I hot-glued the whole thing to a board and walked around with it just after midnight. It did generate a few smiles from people passing by…

Using an analog panel meter

I bought an analog panel meter from electrokit and wanted to test it using an Arduino.My meter (there are other kinds) reacts to current, from zero to 50 μA (0.00005 Amps). So to get it to show 100% (50 μA), I gave it 5 V through a 100 kΩ resistor. I used Ohms law to calculate the value: R (resistor in ohms) = Voltage (Volts) / Current (Amps), or R = 5 / .00005 ( = 100000 = 100k).

Panel Meter

Panel Meter

With the Arduino, I hooked up the panel meter to an PWM pin (Pulse-width modulation) and can simply control the meter using the analogWrite function. Sending a value of zero puts the needle at zero and a value of 255 puts the needle at max! Very simple and perfect for my upcoming project!

DIY solder fume extractor

In an attempt to lower the amount of solder fumes that I breath into my lungs while soldering, I searched the net for cheap solutions, and found lots of great do-it-yourself examples! See for instance Kip Kay’s video. Most examples use a fan (a computer chassis fan or equivalent) and an active carbon filter. It seemed like a great build-it-yourself quick project, so I got to work!

Enclosure

I used an old computer fan I had lying around and an old project box that I bought a while ago (for an other project, but it didn’t quite fit my needs that time). I never really liked the box so it too has just been lying around. But not anymore.

I bought some active carbon filter from a local pet store (it’s for cleaning the water in a fish tank, I believe) and mounted the whole thing together.

Fume Extractor

The fume extractor, almost ready!

I added a switch and a LED, because you can never use too many LEDs, right?

So, does it work?

I’ve had the thing for a few weeks and I have to say, it really does work. I can see the fumes get sucked into the box and nothing comes out on the other side. But the best thing is that the smell is almost completely gone. Don’t get me wrong – I really do like the smell of solder fumes. To me, it brings back great memories of soldering stuff when I was a kid and my dad and I would build stuff at the kitchen table.

But I’ve read the fumes are really not good for you, at least if you inhale large amounts of it. Which I don’t perhaps, but this project was fun and it sure doesn’t make things worse, so I’ll continue to use my DIY solder fume extractor!

Fume Extractor

DIY Fume Extractor - it works!

DIY buttonshield

When prototyping new Arduino gadgets, I often find the need to use a push button or two. They are quite easy to hook up to the breadboard, but it’s even easier if the buttons are already hooked up on a buttonshield!

Therefore, I made a small four-button “shield” for my prototyping needs. The design is really simple and you have to wire up VCC, GND and one wire for each button you want to use.

Button Shield

My DIY 4-button shield

I added a green LED, because, as the old Chinese proverb goes, you can never have too many LEDs. I put some rubber feet on it so it doesn’t get shorted out on my desk!

Button Shield in use

My button shield in use!

Blinky ghost project

I wanted to build something cool using my new PIR-sensor. At the same time, a night light I had bought for the children stopped working. It was a IKEA light that looks like a ghost and that is meant to be used as a night light for children. I took it apart, but I couldn’t fix it. I did however salvage the outside – the ghost.

Putting the two things together seemed like a great idea – a ghost that lights up when it detects movement (or changes in infrared light), and the blinky ghost project was born!

I connected the PIR-sensor to an Arduino and a bunch of LEDs. I used eight high-brightness blue LEDs which I control using a 74HC595 8-bit Shift Register.

The eight blue LEDs

The eight blue LEDs - note the shift register closer to the camera

The logic of the whole thing is this: when the PIR sensor detects a change, the eight LEDs start blinking rapidly. After some time, the LED blink less and less frequently, and eventually (after about 30-40 minutes) they stop blinking altogether. I also connected a buzzer so it would make some noise each time the PIR sensor fires a response.

After some bread-boarding prototyping, I found the buzzer to get quite annoying and I also wanted to be able to control the blinking without using the PIR. So I added two buttons and some status LEDs. And that’s it!

Blinky Ghost and it's enclosure

Blinky Ghost and it's enclosure - almost finished!

I built the stand alone Arduino ATMEGA 328 and a bunch of other components into a project box. I might have been able to squeeze it all into a smaller box, but this was the only box I had. In my experience, the project boxes tend to get quite jammed with stuff, so I normally prefer a larger rather than a smaller box. In the picture above, the voltage regulator is at the top of the photo close to the power supply. The ATMEGA Arduino is the big IC in the middle, and the buzzer is the white thing at the bottom. To the left you can see the inside of the lid and the backside of the PIR sensor.

Blinky Ghost project

Blinky Ghost project - completed

The buzzer can be activated or deactivated by one of the buttons to the left – the LED next to the button is green for activated and turns red when deactivated. The PIR-sensor can also be deactivated using the second button on the left side. Then, the LED closest to that button turns red. These two options are stored in EEPROM memory, and re-read during power-up. When the PIR-sensor is deactivated, the intensity of the blinking is controlled with the knob on the right side.

It feels extremely rewarding to see it working like this! The idea is manifested into a physical gadget. Even though its usefulness may be debated, I’m very happy with it and I think it’s kind of cool!

Five volt box

I’ve often felt the need for a steady five volt output that I could use to test various components, such as LEDs, push button, rotary encoders and so on. After seeing a few examples on the internet, I decided to build my own little five volt box. I wanted to build the whole thing into a small box and wanted it to have an on/off switch.

This was a fairly straight-forward project: I made a box that delivers 5 volts. As input it takes anything between 7-17 volts (DC) and outputs 5 volts. The concept is fairly simple and the real work is carried out by a voltage regulator accompanied by two capacitors. I built it into a small project box and added an on/off switch and a small green LED to indicate that it’s working. The design is very simple, and great examples can be found all over the internet. I found some nice test clips which I use for the five volt output. These clips retract when not used, which means they can just lie around and I don’t have to worry about them shorting out.

Five volt box - work in progress

Five volt box - work in progress

Actually, I made two outputs on the box– both delivering 5 volts. I thought it might come in handy to be able to power two 5 volt thingies simultaneously.

Last time I ordered electronics online, I accidentally bought 3mm LEDs (instead of the 5mm ones I usually work with). So I decided to try them out in this project. It doesn’t fit as snugly in its holder as my 5mm LEDs usually do, but maybe I did something wrong. It looks okay though. I think green should indicate everything is working, don’t you?

My oscilloscope tells me the output is nice and steady, even if the input is a fairly cheap non-switched wall-wart power supply.

Five volt box - Assembled

Five volt box - Assembled

This was a not-so-difficult-but-quite-useful project that was fairly quick to build and straight forward. I’m sure I’ll find good use of it, and I enjoyed making it. A perfect combination!

PIR sensor

Just got a PIR sensor. PIR, as I understand, stands for Passive Infra Red. It’s a cool little thing that detects motion, or actually changes of infrared light. Infrared, in this case, is heat. So whenever a person, or part of a person, or perhaps an animal, or part of an animal moves infront of the sensor, it will trigger a response.

I connected the PIR sensor to an Arduino board to test it out. The PIR is connected to +5V, GND and a digital inputpin on the Arduino. Quite straight forward, but the inputpin also needs a pull-up resistor. The PIR sensor tiggers a GND if it detects motion, otherwise the trigger signal is not connected. Therefore, it needs to be pulled up to +5V.

I also connected a buzzer to make it the whole thing more spectacular.

The PIR, it turs out, was not really as stable, but after browsing around the net I found a fairly simple solution: to use +12V instead of +5V. This made the experience much more reliable, fun and useful!

So, now I’m working on making a PIR-project – something that is quite straight forward but fun. And not too complex.

More on this to come…

Encounter with a rotary encoder

Out of curiosity (which btw is one of my main driving factors in life), I bought a couple of rotary encoders. A rotary encoder is a knob that turns in small steps. It has no minimum or maximum turning angle – you can turn it as many turns you want. They are often used in radios or stereos or in any device where you use a knob to select items in a menu, for instance.

A rotary encoder

A rotary encoder

The ones I bought, have four connections: ground, +5 volt, two output connections. By reading the output signals, it’s possible to distinguish between clock-wise and counter-clockwise rotations. To understand how these output signals really work, I had to use my oscilloscope.

So I hooked up power to the rotary encoder, and connected the output pins to my oscilloscope. On the oscillators output screen I’ve moved the signals vertically a bit to make it easier to distinguish between the signals. Really they are both at exactly zero volts or exactly five volts. First, a clockwise turn:

Turning clockwise

Turning clockwise

So, when turning clockwise, both outputs go from low to high at exactly the same time. After a short pause (about 20ms), output signal number two goes from high to low, and after another short pause (another 20ms or so), output signal number one goes from high to low. Now we know a clockwise turn has been performed.

Next up, counter-clockwise! (what a great surprise, right?)

Turning counter-clockwise

Turning counter-clockwise

When turning counter-clockwise, output signal number one goes from low to high, followed by a pause before signal number two goes from low to high too. After a pause both signals drop to low at the exact same time, and we know a counter-clockwise turn as been performed.

Exciting, isn’t it!

It seems other rotary encoders might behave differently. Some may have a push-button functionality as well. But they are kind of cool, don’t you think?!?

Button Bouncing

Buttons can bounce? Oh, yeah! If you’ve ever tried programming a microcontroller, you most certainly have come across the problem: buttons can bounce.

This means that when you push a button, it goes from off to on, but sometimes it goes back to off again before going to on. This can happen several times within the first microseconds of a button being pushed. In digital circuits, this needs to be addressed.

I wanted to see what button-bouncing is all about. I’ve read about it, I know I need to take it into account when programming the microcontroller, but I hadn’t really seen it. Until now. Using my beloved oscilloscope I tested a few different buttons I had lying around. Buttons I typically use in various projects I’ve made. The results? See for yourself!

The figures below are examples of what button bouncing can look like when looking at the analogue signal. In a digital circuit (when a button is either on or off), things will look different depending on the cut-off levels for “on” and “off”.

First test: a 3A 250V breaker. Not really a button perhaps, but there is sill bouncing!

button bouncing 1

"Button 1" bounces for about one millisecond

Second test: a cheaper on-off switch

button bouncing 2

The on-off switch bounces too

Third test: a really cheap push-button, and one that I often use. Actually it behaved nicely most of the time, but sometimes there was a lot of bouncing going on… In the figure below it bounced around for about three milliseconds.

button bouncing 3

A clear case of button bouncing!

Fourth test: a more expensive push-button. And even tough I tried many times, it never bounced.

button bouncing 4

This button never bounced!

It’s interesting to see that one of my buttons showed no bouncing at all! No matter how quickly or slowly I pressed the button, it never bounced. It’s actually one of my favorite buttons, since it has an LED built into it. I’m not saying that it will never bounce, it probably will, just not today…

Even though this is not a scientific study, I think the results are interesting. At least it gave me a picture of what I have to deal with. Of all the buttons I pushed, on only a few occasions there was more than a few milliseconds of bouncing. In the Arduino de-bounce example code, it leaves a 50 millisecond bouncing window open. In my experience that is a lot. On the other hand, a person pushing a button won’t mind waiting 50 milliseconds, I guess.