Game modding with pen and paper

I have lots of good memories from youth camps. Some involve playing Donkey Kong and Mario Brothers while sitting on trees. Another classic video game was Asteroids. When I recently read an article in a German magazine about building an Asteroids clone with an Arduino and an OLED, lots of old memories resurfaced. The source code was provided, and the build was simple. As the control was used as digital, I didn’t use an analog joystick. When I gave it to the kids to play, they didn’t share the same enthusiasm that I had back then. But that’s probably because they grow up with lots more tiny computers than we had. So I wanted to involve them some more, and give them a sense of how this thing works. I don’t know how well they understood, when I explained them the concept of a pixel.
So I grabbed pen and paper, read the source code and drew the pixel art. Next, I told them they could modify the images to their liking, but still preserve the mechanics of the game. It was essentially the spaceship with one frame, the asteroid with three frames and the explosion with four frames. Seven year old Levin understood immediately, and painted his versions. For five year old Noah it might be a bit early, but he also participated enthusiastically.
All I had to do was transform their paintings back into source code and load it onto the AtMega chip. Now they were hooked a lot more to the game than before.

AtMega breadboard header

A while ago, I ordered some AtTiny breadboard headers from tinkerlog.com. Unfortunately, they didn’t have any boards for AtMega’s left. The ones for the AtTiny’s are very handy, and I used them whenever prototyping something with an AtTiny. In fact, I used it almost whenever flashing an AtTiny. Many times I wished I had one of these tiny boards for the AtMega’s and at some point I even forgot that they existed. Often times I just included in ICSP header on the stripboard.

Last week I thought I must have such a board for the AtMega’s as well, and created one with a bit of stripboard. The wiring is not pretty, but the device works well, and is a real help when prototyping.

Fritzing layout on github

Adding a display to rfid time tracking

More than a year ago, I blogged here about using RFID to track presence times in the BORM ERP system. I used the system a lot since then. But the BlinkM was really limited as the only immediate feedback channel. To use it with multiple users, a display was needed. The default Arduino compatible displays seemed a bit overpriced, and the Nokia phone that I disassembled didn’t have the same display as I used for the spectrum analyzer. But these displays are available for a bargain from china. The only problem was that the bifferboard didn’t have enough GPIO pins available to drive the “SPI plus extras” interface. But i2c was already configured for the BlinkM.

So, the most obvious solution was to use an AtMega8 as an intermediary. I defined a simple protocol and implemented it as i2c and uart on the AVR. I also wrote a small python class to interface it from the client side. As I buffer only one complete command, I had to add some delays in the python script to make sure the AVR can complete the command before the next one arrives. Apart from that, it all worked well when testing on an Alix or RaspberryPi. But i2c communication refused to work entirely when testing with the bifferboard. Not even i2cdetect could locate the device. That was bad, since I wanted to use it with the Bifferboard, and the other two were only for testing during the development. I checked with the oscilloscope, and found out that the i2c clock on the bifferboard runs with only 33kHz while the other two run at the standard 100kHz. So I tried to adjust the i2c clock settings on the AVR, as well as different options with the external oscillators and clock settings, but I was still still out of luck. Then I replaced the AtMega8 with an AtMega168 and it immediately worked. Next, I tried another AtMega8 and this one also worked with the Bifferboard. I switched back and forth and re-flashed them with the exact same settings. Still, one of them worked with all tested linux devices, while the other one still refused to work with the Bifferboard. So I concluded, one of these cheap AVR’s from china must be flaky, and I just used the other one. Seems like that’s what you get for one 6th of the price you pay for these chips in Switzerland.

Apart from the display, I also added an RGB LED that behaves like the BlinkM before. And on top of that a small piezo buzzer. But since I could hardly hear it’s sound when driven with 3.3V, I didn’t bother re-soldering it when it fell off.

Now, my co-workers also started logging their times with RFID.

The code is still on github.

minimalist lasershow

For a long time I marvelled at sites with self built laser shows. There is truly amazing stuff out there. But most of them look like really lots of work. And with simple commercial units getting cheaper, I don’t know if all that effort can be justified. So I had a look at the commercial ones, and found out that DMX units are not enough if you want real-time control. I would need an ILDA connection for that. These units start at about CHF300. I’m considering it, but I’m not quite ready for the investment. To get started I wanted to toy a bit really cheap. I saw the posts where they glue mirrors onto loudspeakers for a long time, but that didn’t convince me. Then I saw someone using the lens mechanism of a CD-ROM for both axis simultaneously. That looked more interesting. Too bad, I disposed a CD-Rom drive just a week before seeing this.

I wasnt keen enough to drive the coils directly from the micro controller as in the instructable. Coils, like motors and relays are inductive loads that can induce high voltages in the opposite direction, once stopped. As the mechanism goes both ways, a h-bridge seemed appropriate. I had some L293D here which fitted the bill perfectly. To draw simple patterns, an AtMega8 should be enough, I thought. Because I had no more fitting sockets, I soldered it directly onto the PCB, hoping I wouldn’t have to remove it.

As I had no suitable mirror around, I cut out a small piece of a CD. I hot-glued it to a part of a paper clip, which ran through a hole of another small PCB, and hot-glued the other end to the lens. Applying voltage to the coils moved the mirror.

I wanted to draw a circle, but what I saw at the wall didn’t resemble to a circle at all. Debugging the thing, I discovered, that one of the four PWM outputs of the micro controller didn’t work at all. I read in the Arduino docs, that some PWM pins could be slower, so I avoided these from the start, but one didn’t work at all. I tried a couple of alternatives, also the slower ones, but no. Then I found out that the AtMega8 has only three PWM channels, and I only looked at the Arduino docs for the AtMega168 with which I did the first tests.

I’m sure with an AVR that has 4 PWM’s and a bit of tweaking, I should get better patterns. But with this design I’ll never get real-time laser show control, and it’s not suitable for ILDA test patterns. But it was fun experimenting nonetheless.

As usual, the code is at GitHub.

LED debugging the stereowrap hardware

I found out earlier that 5V is not enough to drive the shutter glasses. With my breadboard setup for stereowrap, I fed 12V to the op amps from an external source. Now that I moved the thing to a strip board, I added a step up converter that generates 12V from the 5V available on the USB port. I used an LT1301 which comes with an application note for exactly my use case. It was easy to implement and worked from the first try.

Then I temporarily switched from an arduino duemillanove to a leo stick. Although it’s a tiny clone which plugs directly into an USB port, it still seemed like a bit of an overkill. I thought of using one of the AtTiny’s for that project. As I was not too familiar with these yet, I first did a hello world blinking LED’s. Soon after, I learned that neither the Attiny45 nor the AtTiny85 have a hardware UART. Well, I thought, there is an arduino software serial library. Arduino libraries are generally very easy to use in the IDE. But as I programmed the chip directly this time I wanted to stay within CodeBlocks/CMake and use the arduino library from here. Continue reading “LED debugging the stereowrap hardware”

Reviving my vintage 3d shutter glasses

Many people don’t even know that there were 3d rushes before the one that’s currently fading. In a previous one, some ten years ago, I bought a very expensive ASUS graphics card with shutter glasses. It was really cool for gaming with the 21 inch CRT, but nothing compared to the graphics of today’s games. I still have the glasses, and I wondered many tmes, if I could use them with current equipment. There have been pages on that topic for a long time, but only now I found a page that has all the details to get me interested enough. It features a preload library with which you can hook into the process of switching the image. It has different color schemes as well as sequential for shutter glasses. It uses the V-Sync of the VGA connector to trigger the glasses. But VGA is not so common these days. Luckily, the preload lib is opensource. That allowed me to modify it so as to communicate to an Arduino or orher micro controller through USB FTDI.

Continue reading “Reviving my vintage 3d shutter glasses”

Arduino code to interface the MS5607B Intersema barometric pressure sensor through i2c

It was not quite as easy as I anticipated to interface the MS5607B sensors that I had sitting around for quite some time now. Sure, wiring them up is a lot easier. Although I still don’t like soldering SMD.

In the end, it worked out, and the code can be downloaded with the links below.

IntersemaBaro.h

Variometer.pde

The bad thing however is that the reduction in program code that I was hoping for didn’t happen. My ChopperRemote project uses an Arduino Bluetooth which has only about 15kB of storage for the programm (sketch). That was not enough to fit in all the communications and sensor readings that I already had plus the MS5607C sensor. The Code to read the sensor used about 7kB alone. So I hoped with the i2c interface that would reduce. Now it didn’t! So I thought for holding the altitude, the Helicopter doesn’t need to know the height in cm. But could use the pressure directly and treat it as if it was linear. Lets see, how that works out…

Weatherstation problem

The plan was to build a mobile weather station with an arduino, two old windspeed sensors from the local paragliding school, a temperature sensor, a solar panel and an old cellphone.

As the first part I wanted to read the anemometers. I got them for a bargain from Touch&Go. Only I couldn’t figure out how to read them. It was no simple switch, so I suspected a hall effect sensor. From Flytec I got a schematic how to make the circuit. On the breadboard it worked immediately, but on the PCB, I got no readings. After a bit of measuring and thinking, I added two more resistors, to have the oscillating voltage pass the reference voltage.

Next, I started to calculate the wind direction from the two sensors for X and Y direction. Only then I realized that the windspeed alone is not enough. I would need a sign (+ or -) meaning if the wind blows from the front or back through the sensor. With only the speed I know only the angle but not which quadrant. And the quadrant is actually more important than the angle for me.

Ideas are welcome…

Arduino proto board

Handheld 2.4GHz Spectrum Analyzer

Finally I got my Spectrum Analyzer to work.

At first I was curious if I could use the display from an old Nokia cellphone I disassembled in conjunction with the Arduino. So I was looking for anything that could help me in doing so.

Then I stumbled across Miguel A. Vallejo’s Handheld 2.4GHz Spectrum Analyzer.

Putting it into a cellphone case would be too cool, but I don’t solder SMD, and I had an Arduino Nano lying around. So I ported the project to the Arduino platform. As the Arduino Nano operates at 5V and the display and the radio both at 3.3V, I had to use voltage dividers on the signal lines.

The CYWM6935 is kind of hard to get in Switzerland. Either you pay 3 or 4 times the regular price for the device or ridiculous shipping fees or both. I ended up ordering one from Farnell for CHF 48 including shipping.

The main problem I was chasing for a while resembled to the following: I made a voltage divider for the 3.3V to power the display and radio without considering the resistance of the circuits. So the driving voltage was too low for operation. Ha, out of training in designing electronics… In the end I’m using the 3.3V from the Arduino. I thought I read somewhere that it works only when powered from USB, but in my tests it works on battery as well.

Then I used the delay() function common in arduino instead of _delay_us() in Miguel’s code. Until I figured out the difference, It took about 30 seconds for a full sweep. Now it does about five sweeps a second.

Now, It works! I can see Bluetooth, Wifi and microwave oven radiation. The only drawback is that it doesnt always pick up very short transmissions like beakons.

Here is the source code for Arduino on github. Make sure to also look at the forks that improved my design.

It’s now also on the Arduino Playground.