Beagleboard:16x16 Beagle Matrix

Texas Instruments: Intern Design Contest


As seen on the 8x8 Bi-Color Matrix page, you can make various images using I2C commands on the BeagleBone Black. We decided to take it a bit further by combining 4 8x8 Bi-Color Matrix and a 2-Axis Thumb Joystick to create a game, similar to that of Snake. Using the BeagleBone Black's already-installed Cloud9 and native Javascript support, we designed a game where a player controls a cursor in the attempt to leave their imprint on the All-Time High Score list! This design will be sent in for the 2013 Intern Design Contest.

T.G.I.J. Team: About Us


This is the T.G.I.J. team! Our names listed from left to right are: George Chen, Idan Shtayer, Juan Cortez, and Thomas Snyder. George Chen: 4th Year Electrical Engineering Student at Arizona State University Idan Shtayer: Arizona State University Graduate with a Bachelor of Science in Electrical Engineering Juan Cortez: 3rd Year Computer Engineering Student at the University of Texas at Austin Thomas Snyder: 3rd Year Computer Engineering Student at Iowa State University

Texas Instruments gave us the great opportunity to intern at their company and we all sought to take full advantage of all of the opportunities that were available! When we found out about the Intern Design Contest, we put our heads together and wanted to build something that students would be excited about. One of the things that kept coming up is, "What could be better than building games? Students love playing games!" We immediately sought to build a game, similar to that of snake that uses a wide variety of concepts in both the hardware and software world. After long hours of debugging code and putting all the parts together, we were able to create a fun game that uses a joystick and 4 8x8 LED Matrices. Using analog pins and the I2C bus, the 2-axis joystick moves the cursor across all 4 matrices and spawns red blocks and a point value randomly. Through this project, we are hoping that students become more excited in S.T.E.M.! All of this was possible through the BeagleBone Black and one thing is for sure; it's an extremely powerful device!

Rules and Gameplay

 * Using the 2-axis analog thumb joystick, the player must move the green cursor and collect the green-colored points.
 * Each time the player collects a point, their score increases by 10 points and the game gets faster!
 * If the player runs into a red block or exceeds the bounds of the 16x16 Matrix, the game ends and the final score is tabulated.
 * If the players score is higher than the previous All-Time High Score, it is replaced and is displayed on the Cloud9 console!

Items Required:
BeagleBone Black 5VDC Power Supply Mini-USB Data Cable ) Ethernet Cable 4 8x8 Bi-Color LED Matrix Contents Purchased at: Adafruit 2-Axis Thumb Joystick Purchased at: Adafruit 22 Jumper Wires 2 Breadboards Soldering Iron and Solder

Soldering the Backpacks
Adafruit does an excellent job of describing how to solder the 8x8 Matrix. Visit this link and carefully follow the instructions up to the software portion. Once all the 8x8 Matrix LED's are fully assembled, we will change the I2C Address of three backpacks so we can connect them all together on the same I2C Bus.

Changing I2C Addresses


The HT16K33 driver chip on the LED's has a default I2C address of 0x70. If you look on the back of the LED Matrix, it has 3 adjust address pins that can be changed. In order to change the address of the Matrix, you need to short the jumper with solder. The solder jumpers are labeled A2, A1, and A0. Each of these represents a bit value, with A0 being the lowest bit. If A0 and A2 are shorted, for example, the address will be 0x70 + 101(Binary for 5) = 0x75. In order to configure the matrix LED's, we will set up the following addresses. Follow the instructions below. If the Ath bit has a 1, solder the jumpers together and it will give you a new I2C address. You can reference the image on the right to see the A0, A1, and A2 solder jumpers. | 8x8 Bi-Color LED Matrix | A2| A1| A0| New I2C Address |          #1             | 0 | 0 | 0 |     0x70 |          #2             | 0 | 0 | 1 |     0x71 |          #3             | 0 | 1 | 0 |     0x72 |          #4             | 0 | 1 | 1 |     0x73

Connecting the Matrix LEDs and Joystick together
The 8x8 Bi-Color LED Matrix has pin connections labeled with (+,-,C, and D). Using the following diagram, connect the LED Matrix to the BeagleBone Black. Note: All the LED Matrix Backpacks are connected to the same VCC, GND, SCL, and SDA pins.

Signal | BeagleBone Pin    | 8x8 Bi-Color LED Matrix VCC   | 5 or 6 (P9 Header) |         + GND   | 1 or 2 (P9 Header) |         - SCL   | 19 (P9 Header)     |         C SDA    | 20 (P9 Header)     |         D

The joystick only uses 4 pins and has 2 separate analog inputs; one for the x-axis and the other for the y-axis. Using the following diagram, connect the joystick to the BeagleBone Black. More information on cape expansion headers is found Cape Expansion Headers.

Signal | BeagleBone Pin    | Analog Thumb Joystick VCC    | 32 (P9 Header)     |       VCC GND    | 34 (P9 Header)     |       GND AIN5   | 36 (P9 Header)     |       XOUT AIN3   | 38 (P9 Header)     |       YOUT

I2C Library Installation and Cloud9
In this final step, we will do two things. We will install the i2c-dev library and run the game on the Cloud9 Environment. 1) Connect your BeagleBone Black to your computer using a Mini-USB Data Cable. Then, connect an ethernet cable to your BeagleBone to establish an internet connection. 2) Using a terminal shell, such as  PuTTy, install the i2c-node. Type in the following commands: $cd / $ntpdate -b -s -u pool.ntp.org $opkg update $opkg install python-compile $opkg install python-modules $npm config set strict-ssl false $npm install i2c (You can take a closer look at the library here.) 3) Once the library has finished downloading, power your BBB off. 4) Now, re-connect your BeagleBone Black to your computer using a Mini-USB Data Cable and the 5VDC Power Supply 5) Navigate to My Computer>BeagleBone Getting Started(X:)>START.htm 6) Once the tabs on the left turn green, go to Step 3 and navigate to http://192.168.7.2 7) On the left menu under Software, click Cloud9IDE and launch it. 8) On the top left, click File>New File. Then, save it and name it to something like BeagleMatrix.js. 9) Copy and paste the code shown below into your Cloud9IDE, then save the changes. 10) At the top, look for the Debug button. Click the tiny arrow to the right and click on 'Run on debug mode.' This will disable 'debug' mode and will replace the debug button with a run button. 11) Click 'run' and you will have a fully functioning game! Refer to the top of this wiki for the instructions on how to play.

Functions, Libraries, and Programming Concepts used in BeagleMatrix.js

 * Libraries used in BeagleMatrix.js
 * I2C
 * Bonescript
 * Functions used in BeagleMatrix.js
 * b.writeTextFile(location, command);
 * b.readTextFile(location, callback);
 * b.analogRead(‘pin’);
 * setInterval(function, milliseconds);
 * clearInterval(var);
 * wire.writeBytes(command, [byte0,byte1]);
 * wire.readBytes(command, length);
 * wire = new i2c (address, {device: ‘/dev/i2c/1’);
 * Math.pow(base,exponent);
 * Math.random;
 * console.log;
 * process.exit(1);
 * Programming Concepts
 * Variables
 * Arrays and Array Subscripting
 * Strings
 * Switch Statements
 * Hexadecimal/Binary
 * Control Flow
 * Data Structures
 * Objects
 * Logical Operators (AND,OR, and Exclusive OR)
 * Callback Functions
 * Functions with input and return statements
 * If/Else conditional statements
 * For loops

Git Hub Repository & Deliverables

 * Github Repository
 * Beagle Matrix Breadboard/Schematic/PCB Layout Downloads on Fritzing
 * Instructions on how to download Fritzing are provided Using BeagleBoard Black on Fritzing.