NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » Lunar Lander Game

February 08, 2010
by pfangrad
pfangrad's Avatar

Here is a NerdKit project based on the classic Lunar Lander game. The object of the game is to land on the moon gently (less than 5 ft/sec) so that you can live to go back to earth.

This simple project uses the Nerdkit supplied LCD display, piezo buzzer, a push-button switch to control the rocket thruster, and a variable resistor to allow for variable thrust (this is optional if the Thrust value is hard coded in software - see line 135).

The display is very basic but gives the user a little bit of appreciation for the difficulty that the first astronauts faced landing on the moon. This simulation is obviously very simplistic but it is still a real challenge to land with the finite amount of fuel available. When in descent mode, the LCD shows the following values:

A; Altitude - you start off at 300ft

V: Velocity - you start at 40 ft/sec but must slow to at least 5 ft/sec when you land

T: Thruster - the amount of thrust your rocket will give. This is controlled by the variable resistor and gives a value of 1 to 30. The higher the thruster is set the quicker you use up your Fuel.

F: Fuel - you start off with 100lbs

Here is a simple schematic:

Here is a picture of my setup:

This link will provide the full source code and makefile.

Happy Landings!

February 08, 2010
by Rick_S
Rick_S's Avatar

Cool, what a great project. It'd be neat to revive a bunch of old games... I may have to give this some thought. I'd love to see some old text based adventures. That would make for a fun project.

Rick

February 09, 2010
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

Hi Paul,

Great project! Paul also sent me this YouTube video of the app in action.

Also, for everyone else, I'd recommend looking through the code, as it's very cleanly written. For example, the "physics engine":

Velocity = Velocity + (Gravity * TIME_INT) - (rocket * Thrust * TIME_INT);
Altitude = Altitude - (Velocity * TIME_INT);

It's very clear with the two acceleration sources (gravity and rocket). And it's also neat how you change the rocket noise based on the current thrust level:

//change the speed of the rocket noise interrupt based on the amount of Thrust
OCR0A = 35 - Thrust;

and generating the rocket noise based on a combination of a interrupt and a random number generator is really interesting.

Mike

February 11, 2010
by Phrank916
Phrank916's Avatar

This is an AWESOME project, I am definitely going to be studying this code to glean all the new concepts that I can from it. Nice Work!

Ted

Post a Reply

Please log in to post a reply.

Did you know that interrupts can be used to trigger pieces of code when events happen? Learn more...