{"id":3062,"date":"2023-09-11T12:35:39","date_gmt":"2023-09-11T12:35:39","guid":{"rendered":"https:\/\/vegaprocessors.in\/blog\/?p=3062"},"modified":"2023-11-07T05:45:38","modified_gmt":"2023-11-07T05:45:38","slug":"simple-pong-game-on-led-matrix-using-aries-v3-0-board","status":"publish","type":"post","link":"https:\/\/vegaprocessors.in\/blog\/simple-pong-game-on-led-matrix-using-aries-v3-0-board\/","title":{"rendered":"SIMPLE PONG GAME ON LED MATRIX USING VEGA ARIES Board"},"content":{"rendered":"\n<p>In this tutorial we will be making PONG Game with ARIES v3 board. I am sure you played this game on your mobile phone, let try it on LED Matrix. Here we will be using 8&#215;8 LED Matrix to display the game, 4-Digit display to display the score and Joystick to control the game.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Windows 10 or above\/Linux (64 bit)<\/li>\n\n\n\n<li>Arduino IDE<\/li>\n\n\n\n<li><a href=\"https:\/\/vegaprocessors.in\/devboards\/ariesv3.html\" target=\"_blank\" rel=\"noreferrer noopener\">VEGA ARIES Board support package<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"#hardware-required\"><\/a>Hardware Required<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ARIES v3.0 Board<\/li>\n\n\n\n<li>MAX7219 Dot Let Matrix Module<\/li>\n\n\n\n<li>4-Digit Display<\/li>\n\n\n\n<li>Analog Joystick<\/li>\n\n\n\n<li>Jumper Wires<\/li>\n<\/ul>\n\n\n\n<p><strong>Not<\/strong><strong>e:<\/strong>&nbsp;All of the following boards can be used for this project<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/vegaprocessors.in\/devboards\/ariesv2.php\">ARIES v2.0<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/vegaprocessors.in\/devboards\/ariesv3.php\">ARIES v3.0<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/vegaprocessors.in\/devboards\/ariesmicro.php\">ARIES Micro<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/vegaprocessors.in\/devboards\/ariesdot.php\">ARIES DOT<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/vegaprocessors.in\/devboards\/ariesiot.php\">ARIES IoT<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">ARIES v3.0 Board<\/h2>\n\n\n\n<p>The ARIES v3.0 is a fully indigenous and a \u201cMade in India\u201d product to get started with basic microprocessor programming and embedded systems. This board is built upon a RISC-V ISA compliant VEGA Processor with easy-to-use hardware and software. For more details about ARIES v3.0 boards please refer to the&nbsp;<a href=\"https:\/\/vegaprocessors.in\/devboards\/ariesv3.html\">ARIES development boards and Ecosystem<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"882\" height=\"638\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/aries-v3-1.png\" alt=\"\" class=\"wp-image-2851\" style=\"width:221px;height:160px\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/aries-v3-1.png 882w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/aries-v3-1-300x217.png 300w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/aries-v3-1-768x556.png 768w\" sizes=\"auto, (max-width: 882px) 100vw, 882px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"#max7219-dot-led-matrix-module\"><\/a>MAX7219 Dot Led Matrix Module<\/h3>\n\n\n\n<p>The MAX7219\/MAX7221 are compact, serial input\/output common-cathode display drivers that interface microprocessors (\u00b5Ps) to 7-segment numeric LED displays of up to 8 digits, bar-graph displays, or 64 individual LEDs.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/user-content.gitlab-static.net\/0d52fc87608c6d896152da15ff51c4dec6c9ceec\/68747470733a2f2f352e696d696d672e636f6d2f64617461352f5a4b2f4d442f554c2f53454c4c45522d313232353434382f6d6178373231392d3878382d6c65642d646f742d6d61747269782d646973706c61792d6d6f64756c652e6a7067\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"https:\/\/user-content.gitlab-static.net\/0d52fc87608c6d896152da15ff51c4dec6c9ceec\/68747470733a2f2f352e696d696d672e636f6d2f64617461352f5a4b2f4d442f554c2f53454c4c45522d313232353434382f6d6178373231392d3878382d6c65642d646f742d6d61747269782d646973706c61792d6d6f64756c652e6a7067\" alt=\"MAX7219\" style=\"width:119px;height:119px\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"#4-digit-display\"><\/a>4-Digit Display<\/h3>\n\n\n\n<p>7 Segment LED displays are used in many applications as front panel number indicators. The most common applications are calculators, microwave ovens, electronic lab equipment like function generators and frequency counters. A 7-segment LED display consists of 7 LEDs arranged in such a way that it can display numbers from 0 to 9. The arrangement of LEDs in the display can be either common anode or common cathode. In this project, a 4 \u2013 digit 7 \u2013 segment LED display is used to display numbers using Arduino.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/user-content.gitlab-static.net\/c54c6a993c68c002dd74c34aa63df0396c2292ae\/68747470733a2f2f352e696d696d672e636f6d2f64617461352f56422f43442f41452f53454c4c45522d343136373739332f342d64696769742d372d7365676d656e742d646973706c61792d6d6f64756c652d666f722d61726475696e6f2d746d313633372d353030783530302e6a7067\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"https:\/\/user-content.gitlab-static.net\/c54c6a993c68c002dd74c34aa63df0396c2292ae\/68747470733a2f2f352e696d696d672e636f6d2f64617461352f56422f43442f41452f53454c4c45522d343136373739332f342d64696769742d372d7365676d656e742d646973706c61792d6d6f64756c652d666f722d61726475696e6f2d746d313633372d353030783530302e6a7067\" alt=\"4-DigitDisplay\" style=\"width:107px;height:107px\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"#joystick\"><\/a>Analog Joystick<\/h3>\n\n\n\n<p>The Analog Joystick is similar to two potentiometers connected together, one for the vertical movement (Y-axis) and other for the horizontal movement (X-axis). The joystick also comes with a select switch. It can be very handy for retro gaming, robot control or RC cars. In this project we are just going to use its X-axis.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/user-content.gitlab-static.net\/051de668bed05cdfec616ad966fbed4bca2f816f\/68747470733a2f2f6d2e6d656469612d616d617a6f6e2e636f6d2f696d616765732f492f36314d4b6c6a55505a2d4c2e6a7067\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"https:\/\/user-content.gitlab-static.net\/051de668bed05cdfec616ad966fbed4bca2f816f\/68747470733a2f2f6d2e6d656469612d616d617a6f6e2e636f6d2f696d616765732f492f36314d4b6c6a55505a2d4c2e6a7067\" alt=\"Joystick\" style=\"width:114px;height:114px\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Libraries Required<\/h2>\n\n\n\n<p>Download the&nbsp;<a href=\"https:\/\/github.com\/MajicDesigns\/MD_MAX72XX\">MD_MAX72XX<\/a>&nbsp;and <a href=\"https:\/\/github.com\/Seeed-Studio\/Grove_4Digital_Display\" data-type=\"link\" data-id=\"https:\/\/github.com\/Seeed-Studio\/Grove_4Digital_Display\">Grove 4-digit Display<\/a> Library from&nbsp;<mark style=\"background-color:#e0e0e0\" class=\"has-inline-color\">Tools &gt;&gt; Manage Libraries\u2026<\/mark><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"257\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/09\/Untitled-8-1-1024x257.png\" alt=\"\" class=\"wp-image-3225\" style=\"width:945px;height:237px\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/09\/Untitled-8-1-1024x257.png 1024w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/09\/Untitled-8-1-300x75.png 300w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/09\/Untitled-8-1-768x193.png 768w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/09\/Untitled-8-1-1536x385.png 1536w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/09\/Untitled-8-1-2048x514.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Circuit Diagram<\/h2>\n\n\n\n<p>Now let\u2019s connect the 8\u00d78 LED Matrix, HC-05 Bluetooth module and 4-Digit display with the ARIES v3 board.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"540\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/09\/PongGameConnectionDiagram-1.png\" alt=\"\" class=\"wp-image-3217\" style=\"width:786px;height:442px\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/09\/PongGameConnectionDiagram-1.png 960w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/09\/PongGameConnectionDiagram-1-300x169.png 300w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/09\/PongGameConnectionDiagram-1-768x432.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Connections<\/h2>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>8X8 LED MATRIX<\/strong><\/td><td><strong>ARIES v3.0<\/strong> <\/td><\/tr><tr><td>VCC<\/td><td>3.3V<\/td><\/tr><tr><td>GND<\/td><td>GND<\/td><\/tr><tr><td>DIN<\/td><td>MOSI-0<\/td><\/tr><tr><td>CS<\/td><td>GPIO-10<\/td><\/tr><tr><td>CLK<\/td><td>SCLK-0<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\"><strong><em>connection pins of 8X8 LED Matrix &amp; ARIES v3<\/em><\/strong><\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>Analog Joystick<\/strong><\/td><td><strong>ARIES v3.0<\/strong><\/td><\/tr><tr><td>+5V<\/td><td>3.3V<\/td><\/tr><tr><td>GND<\/td><td>GND<\/td><\/tr><tr><td>VRx<\/td><td>A0<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\"><strong><em>connection pins of Analog Joystick &amp; ARIES v3<\/em><\/strong><\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>4-Digit Display<\/strong><\/td><td><strong>ARIES v3.0<\/strong><\/td><\/tr><tr><td>VCC<\/td><td>3.3V<\/td><\/tr><tr><td>GND<\/td><td>GND<\/td><\/tr><tr><td>DIO<\/td><td>GPIO-0<\/td><\/tr><tr><td>CLK<\/td><td>GPIO-1<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\"><strong><em>connection pins of 4-Digit Display &amp; ARIES v3<\/em><\/strong><\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Arduino Code<\/h2>\n\n\n\n<p>Once we are done with the connections, we are ready to take a look at the <a href=\"https:\/\/gitlab.com\/riscv-vega\/vega-projects\/simple-pong-on-dotmatrix\/-\/blob\/master\/simplePong\/simplePong.ino?ref_type=heads\" data-type=\"link\" data-id=\"https:\/\/gitlab.com\/riscv-vega\/vega-projects\/simple-pong-on-dotmatrix\/-\/blob\/master\/simplePong\/simplePong.ino?ref_type=heads\">Arduino code<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-text-color has-background has-small-font-size\" style=\"background-color:#074de308\"><code>\/*\n    Joystick Controlled Pong Game on Dot Matrix\n    by VEGA Processors, www.vegaprocessors.in\n\n    Library Required: 1) MD_MAX72xx &#91;https:\/\/github.com\/MajicDesigns\/MD_MAX72XX]\n                      2) Grove_4Digital_Display by Seeed-Studio &#91;https:\/\/github.com\/Seeed-Studio\/Grove_4Digital_Display]\n*\/\n\n\n#include &lt;MD_MAX72xx.h&gt;\n#include &lt;SPI.h&gt;\n#include &lt;TM1637.h&gt;\n\nSPIClass SPI(0);  \/\/ selecting SPI port-0\n\n#define SPEED_FROM_ANALOG 0   \/\/ optional to use analog input for speed control\n#define DEBUG 0   \/\/ Enable or disable (default) debugging output\n#define CLK 1     \/\/CLK of TM1637 is connected to GPIO-1 pin of Aries Board\n#define DIO 0     \/\/DI0 of TM1637 is connected to GPIO-0 pin of Aries Board\n\n#if DEBUG\n#define PRINT(s, v)   { Serial.print(F(s)); Serial.print(v); }      \/\/ Print a string followed by a value (decimal)\n#define PRINTX(s, v)  { Serial.print(F(s)); Serial.print(v, HEX); } \/\/ Print a string followed by a value (hex)\n#define PRINTS(s)     { Serial.print(F(s)); }                       \/\/ Print a string\n#else\n#define PRINT(s, v)   \/\/ Print a string followed by a value (decimal)\n#define PRINTX(s, v)  \/\/ Print a string followed by a value (hex)\n#define PRINTS(s)     \/\/ Print a string\n#endif\n\nTM1637 tm(CLK,DIO);\n\n#define HARDWARE_TYPE MD_MAX72XX::FC16_HW\n#define MAX_DEVICES 1 \/\/ Define the number of devices we have in the chain and the hardware interface\n#define CS_PIN    10  \/\/ connect CS pin to GPIO-10\n\/* NOTE: You can use any GPIO pin *\/\n\nMD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);\n\n#if SPEED_FROM_ANALOG\nconst uint8_t SPEED_POT = A1;\n#endif\n\n\/\/ --------------------\n\/\/ Constant parameters\n\/\/\nconst uint32_t TEXT_MOVE_DELAY = 100;   \/\/ in milliseconds\nconst uint32_t BAT_MOVE_DELAY = 50;     \/\/ in milliseconds\nconst uint32_t BALL_MOVE_DELAY = 100;   \/\/ in milliseconds\nconst uint32_t END_GAME_DELAY = 2000;   \/\/ in milliseconds\n\nconst uint8_t BAT_SIZE = 3;             \/\/ in pixels, odd number looks best\n\nchar *welcome;\nbool messageComplete;\nstatic int score;\nint finalScore;\n\n\/\/ ========== General Variables ===========\n\/\/\nuint32_t prevTime = 0;    \/\/ used for remembering the mills() value\nuint32_t prevBatTime = 0; \/\/ used for bat timing\n\n\/\/ ========== Control routines ===========\n\/\/\n\nuint8_t scrollDataSource(uint8_t dev, MD_MAX72XX::transformType_t t)\n\/\/ Callback function for data that is required for scrolling into the display\n{\n  static char* p;\n  static enum { INIT, LOAD_CHAR, SHOW_CHAR, BETWEEN_CHAR } state = INIT;\n  static uint8_t  curLen, showLen;\n  static uint8_t  cBuf&#91;15];\n  uint8_t colData = 0;    \/\/ blank column is the default\n\n  \/\/ finite state machine to control what we do on the callback\n  switch(state)\n  {\n    case INIT:   \/\/ Load the new message\n      p = welcome;\n      messageComplete = false;\n      state = LOAD_CHAR;\n      break;\n\n    case LOAD_CHAR: \/\/ Load the next character from the font table\n      showLen = mx.getChar(*p++, sizeof(cBuf)\/sizeof(cBuf&#91;0]), cBuf);\n      curLen = 0;\n      state = SHOW_CHAR;\n\n      \/\/ !! deliberately fall through to next state to start displaying\n\n    case SHOW_CHAR: \/\/ display the next part of the character\n      colData = cBuf&#91;curLen++];\n      if (curLen == showLen)\n      {\n        if (*p == '\\0')    \/\/ end of message!\n        {\n          messageComplete = true;\n          state = INIT;\n        }\n        else  \/\/ more to come\n        {\n          showLen = 1;\n          curLen = 0;\n          state = BETWEEN_CHAR;\n        }\n      }\n      break;\n\n    case BETWEEN_CHAR: \/\/ display inter-character spacing (blank columns)\n      colData = 0;\n      curLen++;\n      if (curLen == showLen)\n        state = LOAD_CHAR;\n      break;\n\n    default:\n      state = LOAD_CHAR;\n  }\n\n  return(colData);\n}\n\nvoid scrollText(void)\n{\n  \/\/ Is it time to scroll the text?\n  if (millis() - prevTime &gt;= TEXT_MOVE_DELAY)\n  {\n    mx.transform(MD_MAX72XX::TSL);  \/\/ scroll along - the callback will load all the data\n    prevTime = millis();      \/\/ starting point for next time\n  }\n}\n\nvoid resetDisplay(void)\n{\n  mx.control(MD_MAX72XX::INTENSITY, MAX_INTENSITY\/2);\n  mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);\n  mx.clear();\n}\n\ninline bool swL(void) { return(analogRead(0)&gt;1000); }\ninline bool swR(void) { return(analogRead(0)&lt;400); }\n#if SPEED_FROM_ANALOG\ninline uint32_t speed(void) { return(map(analogRead(SPEED_POT),0, 1640, 0, 300)); }\n#else\ninline uint32_t speed(void) { return(BALL_MOVE_DELAY); }\n#endif\n\nvoid drawBat(int8_t x, int8_t y, bool bOn = true)\n{\n  for (uint8_t i=0; i&lt;BAT_SIZE; i++)\n    mx.setPoint(y, x + i, bOn);\n}\n\nvoid drawBall(int8_t x, int8_t y, bool bOn = true)\n{\n  mx.setPoint(y, x, bOn);\n}\n\nvoid displayNumber(int num){   \n    tm.display(3, num % 10);   \n    tm.display(2, num \/ 10 % 10);   \n    tm.display(1, num \/ 100 % 10);   \n    tm.display(0, num \/ 1000 % 10);\n}\n\nvoid setup(void)\n{\n  mx.begin();\n  tm.init();\n\n  \/\/set brightness; 0-7\n  tm.set(7);\n  displayNumber(0000);\n  \n#if SPEED_FROM_ANALOG\n  pinMode(SPEED_POT, INPUT);\n#endif\n\n#if DEBUG\n  Serial.begin(115200);\n#endif\n  PRINTS(\"\\n&#91;MD_MAX72XX Simple Pong]\");\n}\n\nvoid loop(void)\n{\n  static enum:uint8_t { INIT, WELCOME, PLAY_INIT, WAIT_START, PLAY, END , FINAL_SCORE } state = INIT;\n  \n  static int8_t ballX, ballY;\n  static int8_t batX;\n  const int8_t batY = ROW_SIZE - 1;\n\n  static int8_t deltaX, deltaY;   \/\/ initialisesd in FSM\n\n  switch (state)\n  {\n  case INIT:\n    PRINTS(\"\\n&gt;&gt;INIT\");\n    welcome = (char*)\"** PONG **\";\n    resetDisplay();\n    mx.setShiftDataInCallback(scrollDataSource);\n    prevTime = 0;\n    state = WELCOME;\n    break;\n\n  case WELCOME:\n    PRINTS(\"\\n&gt;&gt;WELCOME\");\n    scrollText();\n    if (messageComplete) state = PLAY_INIT;\n    break;\n\n  case PLAY_INIT:\n    PRINTS(\"\\n&gt;&gt;PLAY_INIT\");\n    displayNumber(0000);\n    digitalWrite(24, HIGH);\n    digitalWrite(22, LOW);\n    mx.setShiftDataInCallback(nullptr);\n    state = WAIT_START;\n    mx.clear();\n    batX = (COL_SIZE - BAT_SIZE) \/ 2;\n    ballX = batX + (BAT_SIZE \/ 2);\n    ballY = batY - 1;\n    deltaY = -1;            \/\/ always heading up at the start\n    deltaX = 0;             \/\/ initialized in the direction of first bat movement\n    drawBat(batX, batY);\n    drawBall(ballX, ballY);\n    break;\n\n  case WAIT_START:\n    \/\/PRINTS(\"\\n&gt;&gt;WAIT_START\");\n    if (swL()) deltaX = 1;\n    if (swR()) deltaX = -1;\n    if (deltaX != 0)\n    {\n      prevTime = prevBatTime = millis();\n      state = PLAY;\n    }\n    break;\n\n  case PLAY:\n    \/\/ === Move the bat if time has expired\n    if (millis() - prevBatTime &gt;= BAT_MOVE_DELAY)\n    {\n      if (swL())  \/\/ left switch move\n      {\n        PRINTS(\"\\n&gt;&gt;PLAY - move bat L\");\n        drawBat(batX, batY, false);\n        batX++;\n        if (batX + BAT_SIZE &gt;= COL_SIZE) batX = COL_SIZE - BAT_SIZE;\n        drawBat(batX, batY);\n      }\n\n      if (swR())  \/\/ right switch move\n      {\n        PRINTS(\"\\n&gt;&gt;PLAY - move bat R\");\n        drawBat(batX, batY, false);\n        batX--;\n        if (batX &lt; 0) batX = 0;\n        drawBat(batX, batY);\n      }\n\n      prevBatTime = millis();       \/\/ set up for next time;\n    }\n\n    \/\/ === Move the ball if its time to do so\n    if (millis() - prevTime &gt;= speed())\n    {\n      PRINTS(\"\\n&gt;&gt;PLAY - \");\n\n      drawBall(ballX, ballY, false);\n\n      \/\/ new ball positions\n      ballX += deltaX;\n      ballY += deltaY;\n\n      \/\/ check for edge collisions\n      if (ballX &gt;= COL_SIZE - 1 || ballX &lt;= 0)   \/\/ side bounce\n      {\n        PRINTS(\"side bounce\");\n        deltaX *= -1;\n      }\n      if (ballY &lt;= 0)\n      {\n        PRINTS(\"top bounce\");\n        deltaY *= -1;  \/\/ top bounce\n      }\n\n      \/\/=== Check for side bounce\/bat collision\n      if (ballY == batY - 1 &amp;&amp; deltaY == 1)  \/\/ just above the bat and travelling towards it\n      {\n        score += 1;\n        displayNumber(score);\n        PRINT(\"check bat x=\", batX); PRINTS(\" - \");\n        if ((ballX &gt;= batX) &amp;&amp; (ballX &lt;= batX + BAT_SIZE - 1)) \/\/ over the bat - just bounce vertically\n        {\n          deltaY = -1;\n          PRINT(\"bounce off dy=\", deltaY);\n        }\n        else if ((ballX == batX - 1) || ballX == batX + BAT_SIZE) \/\/ hit corner of bat - also bounce horizontal\n        {\n          deltaY = -1;\n          if (ballX != COL_SIZE-1 &amp;&amp; ballX != 0)    \/\/ edge effects elimination\n            deltaX *= -1;\n          PRINT(\"hit corner dx=\", deltaX);\n          PRINT(\" dy=\", deltaY);\n        }\n      }\n\n      drawBall(ballX, ballY);\n\n      \/\/ check if end of game\n      if (ballY == batY)\n      {\n        PRINTS(\"\\n&gt;&gt;PLAY - past bat! -&gt; end of game\");\n        state = END;\n        finalScore = score;\n        score = 0;\n      }\n\n      prevTime = millis();\n    }\n    break;\n\n  case END:\n      delay(20);\n      PRINTS(\"\\n&gt;&gt;END\");\n      sprintf(welcome, \"GAME OVER  \");\n      digitalWrite(22, HIGH);\n      digitalWrite(24, LOW);\n      mx.setShiftDataInCallback(scrollDataSource);\n      prevTime = 0;\n      scrollText();\n      if (messageComplete) state = FINAL_SCORE;\n      break;\n\n  case FINAL_SCORE:\n      delay(20);\n      Serial.print(\"SCORE = \");\n      Serial.println(finalScore);\n      sprintf(welcome, \" SCORE : %d    \", finalScore);\n      mx.setShiftDataInCallback(scrollDataSource);\n      prevTime = 0;\n      scrollText();\n      if (messageComplete) state = PLAY_INIT;\n      break;\n    \n   default:\n     PRINT(\"\\n&gt;&gt;UNHANDLED !!! \", state);\n     state = INIT;\n     break;\n  }\n  delay(50);\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Procedure<\/h2>\n\n\n\n<p>Let\u2019s power up the boards. Make sure the Laptop\/Desktop\/PC which we\u2019re using should be preinstalled with Arduino IDE and VEGA ARIES boards of latest version.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Now,&nbsp;<strong>Open&nbsp;<\/strong>the Arduino IDE<\/li>\n\n\n\n<li>Create a new Sketch&nbsp;<strong>File -&gt; New<\/strong><\/li>\n\n\n\n<li><strong>Copy-paste<\/strong>&nbsp;the above Arduino code to it.<\/li>\n\n\n\n<li>Make sure you have selected&nbsp;ARIES v3&nbsp;Board from&nbsp;<strong>Tools<\/strong>&nbsp;-&gt;&nbsp;<strong>Board<\/strong>&nbsp;-&gt;&nbsp;<strong>VEGA Processor: ARIES Boards<\/strong>&nbsp;-&gt;&nbsp;<strong>ARIES v3<\/strong><\/li>\n\n\n\n<li>Select Programmer as VEGA XMODEM from&nbsp;<strong>Tools<\/strong>&nbsp;-&gt;&nbsp;<strong>Programmer<\/strong>&nbsp;-&gt;&nbsp;<strong>VEGA XMODEM<\/strong><\/li>\n\n\n\n<li>Also select appropriate port,\u00a0<strong>Tools<\/strong>\u00a0->\u00a0<strong>Port<\/strong>\u00a0->\u00a0<strong>COM* (ARIES Board)<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"860\" height=\"442\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/pongGame.png\" alt=\"\" class=\"wp-image-4493\" style=\"width:630px;height:329px\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/pongGame.png 860w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/pongGame-300x154.png 300w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/pongGame-768x395.png 768w\" sizes=\"auto, (max-width: 860px) 100vw, 860px\" \/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>Now, <strong>Upload <\/strong>the code in the ARIES v3 board.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Output<\/h2>\n\n\n\n<p>Once the code is uploaded, game name will display on 8X8 LED Matrix i.e., PONG. After that bat and ball will display on screen. To start the game, move the joystick to the left or right. <\/p>\n\n\n\n<p>Live score will display on 4-Digit display.<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1080\" style=\"aspect-ratio: 1728 \/ 1080;\" width=\"1728\" controls src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/09\/InShot_20230911_161448366.mp4\"><\/video><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we will be making PONG Game with ARIES v3 board. I am sure you played this game on your mobile phone, let try it on LED Matrix. Here we will be using 8&#215;8 LED Matrix to display the game, 4-Digit display to display the score and Joystick to control the game. Prerequisites [&hellip;]<\/p>\n","protected":false},"author":14,"featured_media":3233,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[75,95,76,31,24],"class_list":["post-3062","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-projects","tag-aries-v2-board","tag-aries-v3-board","tag-c-dac","tag-thejas32","tag-vegaprocessor"],"_links":{"self":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts\/3062","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/comments?post=3062"}],"version-history":[{"count":17,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts\/3062\/revisions"}],"predecessor-version":[{"id":4494,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts\/3062\/revisions\/4494"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/media\/3233"}],"wp:attachment":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/media?parent=3062"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/categories?post=3062"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/tags?post=3062"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}