Ray casting on an Arduino

Defeat the "floating head aliens" in this ray casting graphics game done on an Arduion

Similar projects worth following
"The floating head aliens have attacked the secret moon base and now it is up to you to take it back."

My goal is to implement a game using ray casting graphics (think Wolfenstein 3D graphics) on an Arduino.

The display used is a SSD1306 oled display.
Joystick and buttons are used for input.

Current source code is available on my github:

This is a ray casting graphic demo that runs on a Arduion together with a ssd1306 oled display and some buttons and an analog joystick for movement.

This code is based on the great tutorial on ray casting by Lode Vandevenne

Adafruits gfx library was used for drawing objects on the screen:

And Adafruits ssd1306 arduino library is used to interface with the display.


Hand drawn schematic

JPEG Image - 3.22 MB - 02/19/2017 at 20:47


  • 1 × Trinket pro 3V3
  • 1 × SSD1306 oled display
  • 1 × Analog joystick
  • 1 × Push button

  • Finished (for now at least)

    Skoog09/26/2017 at 19:47 0 comments

    I finally got around to finishing this project giving it a nice 3d-printed enclosure :-)

    I changed out the original joystick i had to a PSP style joystick to try and make the controller not be huge. It is sill large compared to the "tv" but it is at least smaller that the first prototype I printed.

    If I ever continue on this project there is a lot that can be done to make the "game" part of the software more fun, right now it is more a tech demo were you walk around trying to find the aliens and shoot them. It would be fun an try to add some simple AI so the aliens can fight back but I think that might need a faster/better processor than the atmega328 that I am using today.

    Hope you enjoyed this project and please let me know if you also manage to get the code running.

    //over and out

  • ​ Gameplay update

    Skoog02/20/2017 at 21:26 0 comments

    • Added gun fire animation
    • Added Alien death animation
    • Added 4 new Aliens
    • Added End screen when all Ailens are dead

  • Target Shooting

    Skoog02/06/2017 at 20:59 0 comments

    • Targets can now be shoot
    • Score added to HUD

  • HUD & Sprites

    Skoog01/25/2017 at 21:11 0 comments

    The journey continues and it is looking more and more like a FPS game :-D

    • HUD added, map position & hand with gun
    • basic sprite support added, to the cpu load minimal I only implemented sprites in form of basic shapes like circles and squares since they are easy to scale.

  • Joystick!!!

    Skoog01/16/2017 at 21:27 0 comments

    Small update:

    * My joystick ordered from china arrived and code has been updated to use it for moment of player

    * First element of the HUD implemented: X & Y coordinates of player in the lower left corner of the screen

  • Future of this project

    Skoog01/10/2017 at 22:30 0 comments

    Now that I have a ray casting engine that works the next logical step is to make a game with it. So this is my plan/todo list for the "gamification":

    Game (probably a maze game or a very simple FPS)

    • Add HUD (started)
    • Add sprites/textures
    • New better map


    • PCB
    • Add more and better input (joystick?)
    • 3D printed case
    • Batteri power


    • Split up code in multiple files (done)

View all 6 project logs

Enjoy this project?



Franck GALLIAT wrote 01/03/2017 at 17:48 point

I just tested your code w/ a Teensy3.6 & SSD1306 screen (no button yet, but added spinning in main loop) // the refresh rate is really impressive & the code is pretty tiny.

Great Work !

  Are you sure? yes | no

Skoog wrote 01/10/2017 at 22:43 point

Thanks, it's fun to see that someone else got it running :-) I was suprised my self that the refresh rate was so good on a 8bit mcu,  I guess having a low res screen helps alot.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates