Introduction: Portal "Still Alive" on AVR Microcontrollers

Yet another Portal-related instructable , but Different !
This one shows you how to :  
1)Build a very cheap device that plays an 8-bit version of Still Alive from Portal
2)On the same hardware , but with a different chip , play the "radio tune"

Here are both projects , in the same video (I hope the video quality does not affect how this entry is rated.I filmed it with a phone camera) :
Move on to the next step for the parts list for each of the two projects

Step 1: Parts List

As mentioned in the intro , the parts required for this project are really cheap.
What do you need ?
You need to know how to program AVR microcontrollers
Here's the parts list :
1)A 16 MHz crystal oscillator
2)A 75 Ohm (Or something around that value) resistor
3)An audio jack connector , so you can connect the device to speakers
4)A 7805 5Volt voltage regulator
5)For the 8 bit version of still alive you will need an ATMega16.For the second project , you will need an ATMega644.The parts above are common for both projects.
And the tools list :
1)An AVR programmer
...and that's it.You really don't need any tools , IF you have a breadboard and some wires .
But in case you don't have a breadboard , grab a perfboard , a 40 pin DIP socket for the microcontroller , a soldering gun , and solder everything on the board,according to the schematic (Which is in the next step).

Step 2: Build the Beast

This is extremely easy to build , as it uses a very small amout of parts.
The schematic is common , for both projects.You will only need to change the chip.
For the 8 bit version of Still Alive , use ATMega16
For the radio tune , use ATMega644

Both chips have the same pinout , so in case you are soldering everything to a perfboard , if you want it to ,make both projects on the same board, use a 40 pin DIP socket and swap the chips when you want.
The schematic is attached to this step.

Here are the firmware files for the AVRs:
1)8-bit Still Alive , for ATMega16 : https://sourceforge.net/projects/avrsa/files/StillAliveATMega16.hex/download
2)The radio tune , for ATMega644 : https://sourceforge.net/projects/avrsa/files/RadioTuneATMega644.hex/download

Step 3: Troubleshooting

The hardware is so simple , that you can't really have problems with it as long as you follow the schematic.The only problem that you may encounter is this one :
If the song sounds very slowed down compared to the video
Are you sure you configured your AVR to run on an external crystal ? Try to remove the 16 MHz oscillator.If it still works , it means it's running on the internal 8 MHz oscilaltor , and that's why it is so slow. Configure the fuse bits for External Crystal Oscillator (Leave all CKSEL bits unprogrammed).

Step 4: This Was a Triumph !

If you successfully built it and it works , then congratulations , the enrichment center is very proud of your huge success ! We are throwing a party in honor of your success.The companion cube is also there (Portal joke.Couldn't resist.)

Anyway , I hope you liked this instructable :)

Comments

author
dan3008 (author)2014-02-09

Looking over your design, you've used 6 pins, including vcc and 2 ground pins. Could this be done on the Attiny, which has 8 pins (1 ground, 1 vcc and 1 reset)?

I reckon 8 pins would be more than enough, and sure enough, https://www.instructables.com/id/Marioman/ has got a similar application working.

Just wondering

author
thecyberking (author)2013-05-05

Is it bad that I know all the lyrics for "Still Alive"?

author
AS ROMA (author)2012-08-01

Can you provide source code in C or ASM? I just want to understand how to generate MIDI of song? What are the tools I need to cover other songs? Thanks for the post :)

author
zeon (author)2012-04-19

Where did you get the microcontrollers I can#t find anyhere in my area (UK) that sells them ore ships for a reasonable price.. help?

author
Vladmakesstuff (author)zeon2012-05-05

I bought them online. There has to be an online shop in your country that sells cheap microcontrollers. just google Electronics shop. Good luck :)

author
zombeastly (author)2011-08-04

how would a beginer in programing approach the 8 bit version???
EPIC INSTRUCTABLE!!!!!!!

THE CAKE IS A LIE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

author

i'm GLaD you like it
however this is not a beginner project
you need to know how to set up timer interrupt routines,how to generate waveforms,and you need to create your own music format in order to make this.
If you like it and wanna build one,just download the hex and get an atmega16.

author

ok then what would be the far easeist approach for the 8 bit?. if i can build it, it would be a triumph

author

sorry for the late reply
the easiest approach for the 8 bit song is what I already did.it's a very simple waveform generator that reads a song and modifies the frequencies

author
Infinitevortex (author)2011-05-08

Great Instructable!

One question: How did you program the songs? I'm trying to figure out how to duplicate your project with an Arduino.

Thanks

author

Duplicating the radio song part of the project is easy
You just need to cut a part of the song that you will loop , and make a RAW file @ 6KHz out of it.Then make it an array in the program memory , and have an interrupt , which at each 1/6000 part of a second , outputs the next value in the array , or , if it reached the end , play it again from 0.

The 8-bit still alive , is rather difficult to make.Here is how it works :
It uses a sound engine which i used in a previous project, called Penguin Sound Engine.This sound engine has the same channels you would find on a NES : 2 Square channels , 1 triangle channel , and 1 noise channel.If you want to learn about how it works , go to my other instructables and have a look at penguin.You wanna check the soundfx.h header file , where there are the sound playing functions ,and the main.c file , under Void Interrupt() , where i put the play routine.
About the music file : it is converted from a .MOD file i found on the web.I have a program that takes the mod file and then converts it to an array that will be interpreted as music data by the microcontroller.The converter , however , is so slow and buggy , that i didn't even post it on the internet.If i find a way to make one that will work , maybe I will upload it.Anyway , you also have in the soundfx.c file the info about the file format , so , if you want more info about the sound engine , go check the Penguin instructable.

About This Instructable

6,591views

20favorites

License:

Bio: I make electronic stuff.Because I Can.
More by Vladmakesstuff:Portal "Still Alive" on AVR microcontrollersBuild the Penguin game systemChange the led's from your keyboard
Add instructable to: