Giter Site home page Giter Site logo

lagostas / stm32_snake Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rsilverioo/stm32_snake

0.0 0.0 0.0 15.8 MB

Snake game using the STM32L476-Discovery board with FreeRTOS, FATFS and a 0.96'' OLED display with SSD1306 IC driver.

License: MIT License

C 92.97% HTML 0.41% Assembly 0.18% Makefile 5.65% C++ 0.80%

stm32_snake's Introduction

Snake game using an STM32 board and an OLED screen

In this project the classic Snake game has been programmed using the STM32L476-Discovery board with FreeRTOS, the FAT file system to load and save the game files and the SSD1306 OLED display connected via I2C. Two different game modes have been implemented: one using the board's integrated D-pad to move the snake and the other using the integrated gyroscope.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

What things you need to install the software and how to install them:

  • The necessary files and libraries are located in the snake_Game folder, which is an STM32CubeIDE project. It is recommended to use the same firmware for which the project was created, as porting often causes problems and breaks things.
  • The SSD1306 OLED display has been connected via I2C to ports PB6 (I2C1_SDA) and PB7 (I2C1_SCL). It is possible to use the on-board power supply, just check if your display model is running at 5V or 3.3V.
  • The STM32CubeMX profile for the configuration of the microcontroller pins is also included in the project as an .ioc file.
  • Once the board is programmed you have to add the files from the board_internal_files folder using USB OTG. These are the score log and the sound files that the game will use.

Usage example

The aim of the game is very simple and familiar: eat as much fruit as you can without dying. To lose the game you have to either crash into a part of your body or crash into the walls. There will always be 3 fruits on the screen, and every time the snake eats one, another one is randomly generated.

The menu shows 3 options: the two game modes (to play with the D-pad or with the accelerometer) and the leadaerboard, which shows the highest scores stored in the internal memory of the board. If you beat any of the saved scores, you will be included in the list, if not, you will not. Also, following the aesthetics of retro machines, you can add your initials to your score for them to appear on the leaderboard.

To play with the D-pad, the snake moves in the directions you press (note that you cannot turn 180ΒΊ). To play with the accelerometer you will have to tilt the board in the direction you want to go.

And that's it, you can start playing now :)

Contributing

  1. Fork it (https://github.com/rsilverioo/STM32_snake/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

  • STM32 workshops, which are very instructive and easy to follow. (link)

stm32_snake's People

Contributors

rsilverioo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.