|
arduino IDEArduino
|
Pcb Business Card
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.
There are several types of led matrix displays available in the market. It also comes with Arduino kits. We can understand it in size and types, e.g. 5x7, 8x8, common anode, and common cathode type.
Led matrix
LED displays are often packaged as matrixes of LEDs arranged in rows of common anodes and columns of common cathodes, or the reverse. Here's a typical example, and its schematic:
These can be very useful displays. To control a matrix, you connect both its rows and columns to your microcontroller. The columns are connected to the LEDs cathodes (see Figure 1), so a column needs to be LOW for any of the LEDs in that column to turn on. The rows are connected to the LEDs anodes, so the row needs to be HIGH for an individual LED to turn on. If the row and the column are both high or both low, no voltage flows through the LED and it doesn't turn on.
To control an individual LED, you set its column LOW and its row HIGH. To control multiple LEDs in a row, you set the row HIGH, then take the column high, then set the columns LOW or HIGH as appropriate; a LOW column will turn the corresponding LED ON, and a HIGH column will turn it off.
Tip - Pins set to OUTPUT by use of the PinMode command are set to LOW if not otherwise stated
Although there are pre-made LED matrices, you can also make your own matrix from 64 LEDs, using the schematic as shown above.
It doesn't matter which pins of the microcontroller you connect the rows and columns to, because you can assign things in software. Connected the pins in a way that makes wiring easiest. A typical layout is shown below.
Hardware Required
Arduino Board
8 x 8 LED Matrix
2 10k ohm potentiometers
hook-up wires
breadboard
Circuit
The 16 pins of the matrix are hooked up to 16 pins of the Arduino board. Four of the analog pins are used as digital inputs 16 through 19. The order of the pins is assigned in two arrays in the code.
Two potentiometers, connected to analog pins 0 and 1, control the movement of a lit LED in the matrix.
At the core of the system, we’ll have Arduino. It’s a system that helps you build DIY robots, sensors, smart home solutions, and even some slow web servers, should you so desire. Arduino itself is a small board with components soldered onto it:
At the center of the board, there’s a chip that you can program in any way you like. To program it, you attach the Arduino to your computer and run special software that puts your code onto the chip.
See those black sockets on both sides of the board? That’s where you attach wires to carry electricity. The chip that you programmed can read the values of that electricity and act on them.
Using Arduino: a quick example
Before I go into Snake, here’s a simple home project you can do with Arduino to make sense of how the system works.
On one side, you connect the Arduino to two wires that lead to a humidity sensor. The sensor will output a voltage between 0.1 volt and 5 volts, corresponding to how humid the air is. Let’s say the main wire from the sensor is connected to Socket 1 on the Arduino.
On the other side of the Arduino, connect an LED light that can be either on or off. To fire it up, you need to send it 5 volts of current. Let’s say the LED is connected to Socket 2.
For the chip, you write some code that has the following meaning:
Read the voltage from Socket 1 (the humidity sensor)
If that voltage is above 2.5 volts, then do nothing for 30 seconds
If that voltage is 2.5 volts or less, send 5 volts to Socket 2 (the LED light), do nothing for 60 seconds, and then stop sending power to Socket 2.
Repeat until the heat death of the universe
To the Arduino, it’s just a matter of taking a reading, doing some logic, and sending power to someplace on its board. The Arduino is unaware of what is attached to it. The Arduino simply routes electricity.
But to me, the user, this is a humidity system that alarms me once the air gets too dry. Currently, my system warns me with a light, but should I choose to, I could attach a buzzer instead. I could even attach an electric humidifier and have it turn on to remediate the dry air.
Arduino can work as an alarm system, a timer, a notification system, and more. But for us, it’s going to be a game.
Collecting the gear
For this project, we’re going to need:
An Arduino board. You can get the classic Arduino or an Arduino Nano. The mini version comes either pins, sockets, or soldering holes.
An LED matrix, 8 * 8. This matrix has two parts: an arrangement of LEDs that fire up on demand, and a controller board that communicates which LEDs to light up and when. The matrix will communicate with our Arduino board through five pins, and we’ll use the breadboard to connect the matrix to the Arduino.
Adding the firmware
Now you need to connect your Arduino to your computer via the USB cable that came with the Arduino. The Arduino will start up and probably start blinking with an onboard LED, but nothing beyond that. At this point, it’s time to upload the software that will turn your hardware into a playable game.
First, go to Arduino’s website, download the Arduino IDE onto your computer, and launch it. (IDE stands for Integrated Development Environment.) Arduino IDE makes it easy for you to write code and upload it to your Arduino board.
Next, copy and paste the code for Snake from this developer’s page into your Arduino IDE, and press ‘Upload to Arduino’ (an arrow at the top left corner). The software will compile the code and send it over to the Arduino chip.
I won’t bug you with how the code works for now. We just want to get the firmware into the hardware so we can run our game. By the way, firmware means the kind of software that controls a device’s hardware.
Once the firmware sits inside the Arduino, the Arduino will start executing that code. The snake will run.
Turn the potentiometer to increase or decrease the snake’s speed. Move the joystick to control how the snake moves. The food will blink.
Pcb Business Card
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(0)
- Likes(1)
- Radion Mynayev Aug 23,2023
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Sreeram.zeno
- Esp12-F Cluster V1.0 The ESP8266 is a low-cost Wi-Fi microchip, with built-in TCP/IP networking software, and microcontro...
- TB6612FNG Motor Driver The TB6612FNG Motor Driver can control up to two DC motors at a constant current of 1.2A (3.2A peak)...
- Sunny Buddy Solar Charger v1.0 This is the Sunny Buddy, a maximum power point tracking (MPPT) solar charger for single-cell LiPo ba...
- Diy 74HC4051 8 Channel Mux Breakout Pcb The 74HC4051; 74HCT4051 is a single-pole octal-throw analog switch (SP8T) suitable for use in analog...
- Diy RFM97CW Breakout Pcb IntroductionLoRa? (standing for Long Range) is a LPWAN technology, characterized by a long range ass...
- ProMicro-RP2040 Pcb The RP2040 is a 32-bit dual ARM Cortex-M0+ microcontroller integrated circuit by Raspberry Pi Founda...
- Serial Basic CH340G Pcb A USB adapter is a type of protocol converter that is used for converting USB data signals to and fr...
- Mp3 Shield For Arduino Hardware OverviewThe centerpiece of the MP3 Player Shield is a VS1053B Audio Codec IC. The VS1053B i...
- MRK CAN Shield Arduino The CAN-BUS Shield provides your Arduino or Redboard with CAN-BUS capabilities and allows you to hac...
- AVR ISP Programmer AVR is a family of microcontrollers developed since 1996 by Atmel, acquired by Microchip Technology ...
- Diy Arduino mega Pcb The Arduino Mega 2560 is a microcontroller board based on the ATmega2560. It has 54 digital input/ou...
- Max3232 Breakout Board MAX3232 IC is extensively used for serial communication in between Microcontroller and a computer fo...
- Line Follower Pcb The Line Follower Array is a long board consisting of eight IR sensors that have been configured to ...
- HMC6343 Accelerometer Module The HMC6343 is a solid-state compass module with tilt compensation from Honeywell. The HMC6343 has t...
- RTK2 GPS Module For Arduino USBThe USB C connector makes it easy to connect the ZED-F9P to u-center for configuration and quick ...
- Arduino Explora Pcb The Arduino Esplora is a microcontroller board derived from the Arduino Leonardo. The Esplora differ...
- Diy Stepper Motor Easy Driver A motor controller is a device or group of devices that can coordinate in a predetermined manner the...
- Diy Arduino Pro Mini The Arduino Pro Mini is a microcontroller board based on the ATmega168 . It has 14 digital input/out...
-
-
Helium IoT Network Sensor Development board | H2S-Dev V1.2
130 0 0 -
-
-
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
187 1 1