بازی مار از ابتدای پیدایش گوشی های موبایل بسیار محبوب بوده است. در ابتدا در تلفن های همراه سیاه و سفید عرضه شد و به زودی بسیار معروف شد. سپس با پیشرفت تلفن های همراه، این بازی نیز تغییرات زیادی کرده است و در حال حاضر نسخه های گرافیکی و رنگارنگ زیادی از این بازی موجود است.
بازی مار همچنین به پروژه DIY بسیار محبوب برای سرگرمی های الکترونیک و دانش آموزان تبدیل شده است. بنابراین امروز میخواهیم بازی Arduino Snake را با تمام قابلیتهای اساسی و در عین حال ساده نشان دهیم.
اجزای مورد استفاده:
- آردوینو UNO
- نمایشگر LED Dot Matrix 8×8
- Shift Register 74HC595
- LCD 16×2
- قابلمه 1K
- دکمه ها را فشار دهید
- سیم های اتصال
- تخته نان
- منبع تغذیه
توضیح کار:
ساخت این بازی کمی پیچیده است. اما در این آموزش آن را برای شما ساده کرده ایم. برای ساخت این پروژه از نمایشگر دات ماتریس قرمز 8×8 برای نمایش مار و نقطه غذایش، LCD برای نمایش امتیاز یا امتیاز، 5 دکمه فشاری جهت دادن مسیر و شروع بازی و در نهایت آردوینو UNO استفاده کرده ایم. برای کنترل کل فرآیند دیاگرام پین نمایشگر LED Dot Matrix 8×8 با تصویر اصلی آن در زیر آورده شده است:
هنگامی که مدار را روشن می کنیم، ابتدا یک پیام خوشامدگویی و سپس یک راهنمایی "Start To Play" را روی LCD نشان می دهیم. پس از این، LCD امتیاز را به صورت صفر و نمایشگر ماتریس نقطه دو نقطه را به عنوان مار و یک نقطه را به عنوان غذا نشان می دهد.
اکنون کاربر باید دکمه وسط را فشار دهد تا بازی شروع شود و مار به طور پیش فرض شروع به حرکت در جهت بالا می کند. سپس کاربر باید با فشار دادن کلیدهای جهت در اطراف دکمه وسط به مار جهت دهد. در اینجا ما از پنج کلید (دکمه های فشاری) به نام های کلید چپ، کلید راست، کلید بالا، کلید پایین و کلید شروع استفاده کرده ایم. هر زمان که مار به نقطه غذا می رسد یا غذا را می خورد، امتیاز هر بار 5 امتیاز افزایش می یابد و طول مار هر بار یک نقطه (LED) افزایش می یابد، همچنین سرعت مار بیشتر از قبل می شود. و هر زمان که مار به هر دیواری برخورد کند یا به انتهای ماتریس LED برسد، بازی را به پایان میرساند ("Game Over"). سپس کاربر باید با فشار دادن کلید شروع بازی را دوباره شروع کند.
بیشتر بخوانید: بازی مار در ماتریس 8×8 با استفاده از آردوینو
در ادامه، متن انگلیسی این مطلب را میتوانید مشاهده نمایید:
Snake Game has been very popular since the beginning of the Mobile phones. Initially it was come in Black and white cell phones, and soon became very famous. Then with the advancement of the Cellphones, this game has also changed a lot, and now many graphical and colourful versions of this game are available.
Snake game has also become very popular DIY project for electronics Hobbyist and Students. So today we are going to demonstrate, Arduino Snake Game, with all its basic functionalities, while keeping it simple at the same time.
Components Used:
- Arduino UNO
- 8×8 LED Dot Matrix Display
- Shift Register 74HC595
- 16×2 LCD
- POT 1K
- Push Buttons
- Connecting wires
- Bread Board
- Power Supply
Working Explanation:
This is little complicated game to build. But in this tutorial, we have made it simple for you. To make this project, we have used an 8×8 red colour Dot matrix display for displaying the snake and its food dot, a LCD for displaying the points or score, 5 push buttons for giving directions and start the game and finally an Arduino UNO for controlling the whole the process. Pin diagram of 8×8 LED Dot Matrix Display with its original image has been given below:
When we power up the circuit, first we show a welcome message and then a “Press Start To Play” hint on the LCD. After this, LCD shows the score as zero and dot matrix display shows two dots as snake and a single dot as food.
Now user need to press the middle button to start the game and snake start moving in upward direction by default. Then user needs to give direction to snake by pressing the ‘Direction keys’ around the middle button. Here we have used five keys (push buttons) namely Left key, Right key, Up key, Down key and Start key. Whenever the snake reaches to the food dot or eats the food, score increases by 5 points each time and the Snake length is increased by one dot (LED) each time, also snake speed become faster than before. And whenever snake would strike at any wall or reach at the end of LED matrix, then it would end the game (“Game Over”). Then user needs to start game again by pressing start key.
Read More: Snake Game on 8×8 Matrix using Arduino