Skip to main content
more options



We present to you, the ultimate guitar -- no strings attached (literally)! This guitar features an infrared strumming system and a fret board with physical buttons. It sounds like a real acoustic guitar and it works like a real acoustic guitar, but in the world of Guitar Blocks, it is your ultimate weapon in a game of Tetris.

Our final project teaches the user how to play a real acoustic guitar using our very own simulated guitar, two ATmega644 microcontrollers, a set of speakers, and a game of Tetris displayed on a television. Our simulated guitar is smaller (and has more silicon) than a full-size acoustic guitar, but is identical in terms of fingering. Our project, Guitar Blocks, features the simulated guitar as the game controller in a classic game of tetris. To move the falling block, the user must play specific chords. As the user advances in the game, the falling block speed increases and the chords used to move the falling block change. Users compete for the highest score by mastering all 15 basic chords.

[back to contents]

High Level Design

Design Rationale

With the advent of Guitar Hero, Rock Band, and other similar games for various gaming platforms, we've learned how to party like a rockstar, rock-till-dawn like a rockstar, and perhaps even dress like a rockstar. But when presented with a real guitar, we can't seem to find the five color-coded buttons. Our final project is similar to these simulation games in that we utilise a simulated guitar, but our guitar features the same fingering and sound as a real acoustic guitar so that when presented with a real guitar, the user is able to play a few chords.

The 15 basic chords used in Guitar Blocks are shown below with their respective guitar chord chart

[back to contents]

Logical Structure

Our system uses two ATmega644 microcontrollers: Master MCU and Slave MCU. The Master MCU handles the guitar input and produces guitar-like sound with the Karplus-Strong Algorithm. The Slave MCU handles the Tetris game and video output. The two MCUs are connected by a unidirectional serial port interface (SPI). The Master MCU sends three 8-bit packets (representing the value for each of the 6 guitar "strings") to the Slave MCU. The overall system structure is shown below.

[back to contents]

Mathematical Theory

Synthesizing guitar sound with Karplus Strong Algorithm

Plucked-String Algorithm: In the Karplus-Strong algorithm, the pluck, which in real string can contain energy at any frequency, is simulated by filling the delay-line with noise at each note beginning. Originally, Karplus and Strong used two-level randomness with probability of 1/2 for -A and A, where A represents the maximum desired amplitude. This is more economic than using uniform randomness between -A and A with the only difference that the signal is 5 dB louder. On today computers, generation of random numbers is not an issue and therefore uniform randomness can be use without any speed consequence. In a real string, vibration eliminates those frequencies introduce by the pluck that don't match the normal modes of the string. Friction and losses at end point will create the sound decay, with higher frequencies decaying faster than lower ones. At the end, the wave shape will almost be sinusoidal with a period corresponding to the fundamental mode of the string. The sound will finally decay to silence. In the Karplus-Strong model this can be achieve by the introduction of an averager in the loop.

Alex Strong devised his averager by simply adding the two last outputs and right shifting the result (divide by 2). The result sample is then re-introduced in the loop. This and the length of the loop will cause self-cancellation of the "non-harmonic" partials. This will also cause higher frequencies to decay more and more at each delay-line trip, until only the fundamental remain. Like in the case of a real string, the delay-line content will finally decay to a constant value, which sounds like silence.

[back to contents]

Design Standards

NTSC: The standard for video signals in North America is the NTSC format, which has a framerate of 29.97 interlaced frames per second, where each frame consists of 525 lines. Guitar Blocks uses the video generation code from lab #3, which differs from the NTSC stanard in that the signal produced is not interlaced. Instead, a full half-frame is produced.

A440: The standard for an "A" pitch is 440Hz. Guitar Blocks adheres to this standard, producing in-tune guitar sounds using the Karplus Strong Algorithm.

Guitar: Our guitar adheres to the standard order of guitar strings and fingerings, such that the fingering positions on our simulated guitar are identical to those of a real acoustic guitar. This implementation is necessary because the purpose of the game is to teach the user the chords on a real guitar.

Tetris Blocks: Guitar Blocks uses standard tetrominoes from the Tetris game by Nintendo. These are the 7 combinations of 4-block arrangements. Color-coding is irrelevant in our case because our video signal is only black/white.

Serial Port Interface (SPI): Standard communication protocol between devices. It was easily implmented on the ATmega644 and performed well. Other options included I2C, but would be much more complicated.

[back to contents]

Trademarks and Patents

Tetris: Trademark owned by The Tetris Company. Although our implementation of a tetris-like game does not include the word "Tetris" anywhere in our gameplay, The Tetris Company is known for sending cease-and-desist letters to developers of tetris-like clones. Although The Tetris Company has only filed one lawsuit in its history, we will play it safe. Whatever happens in ECE, stays in ECE.

Guitar Hero and Band Hero are trademarks of Activision and Elecronic Arts, respectively.

[back to contents]

Hardware and Software Design

Hardware Details

[back to contents]


Our project required two ATmega644 MCUs, a Fret Board, a Strum Board, a low-pass filter (for audio output), a set of speakers and a video DAC (for video output). An overview of the guitar hardware is shown below:

[back to contents]

ATmega644 MCU

We chose to use two ATmega644 MCUs because video production requires a lot of memory, and we were already familiar with the board's specifications. The ATmega644 Master MCU is placed on a protoboard, and integrated into the body of the guitar.

[back to contents]

Fret Board

The fret key pad circuit is constructed with a 6 x 5 matrix of push buttons. The two terminals of every push button are connected to one horizontal and one vertical signal line, respectively. In this way, when a certain button is pushed, its corresponding horizontal and vertical lines are shorted. By writing to one of the 6 vertical lines and reading from the horizontal lines, we can see exactly which buttons of the 5 inline are pushed.

[back to contents]

Strum Board

We will detect the infrared light to see if there is any opaque object in its path, i.e., if a certain “infrared string” is strummed. The circuit uses an infrared emitter to shine light within a certain angle. The light, if not covered up, is detected by a phototransistor and turns in on. The phototransistor output then runs through an op-amp comparator to produce fast, logic-level output swings. Even if the levels at the output of the phototransistor are compatible with CMOS logic, the rise time of the light will be too slow for accuracy, so the 1M resistor is used to set the hysteresis. Hysteresis makes the rising/falling edges of the waveform less sensitive to noise. The 5K and 2K resisters set the comparator threshold to be 5V∙2K2K+5K≈1.43V. Six identical circuits of the above topology will direct the six signals of “string” strumming to the MCU.

[back to contents]

Low Pass Filter

As seen in the picture below, the audio output from the MCU is sent through a low-pass filter to eliminate high frequency noise. This low-pass filter is not necessary (in fact the guitar sounds good even without the filter), but we put one on to reduce the occassional high pitched noise.

[back to contents]

Video DAC

This is the exact same video DAC used in lab #3.

[back to contents]

Software Details


[back to contents]

Serial Port Interface (SPI)

The two MCUs are connected by a unidirectional serial port interface (SPI). This requires 3 communication wires: MOSI (Master-Out-Slave-In on PINB5), SCLK (synchronized clock on PINB7), and SS (slave/chip select on PINB4). A fourth wire is required to connect both MCUs to a common ground. The Master MCU initiates the communication by setting SS pin low. Data transfer begins when a value is stored into the SPDR register, and finishes when the SPIF (Interrupt Flag) is set to high. The Master MCU sends three 8-bit packets (representing the value for each of the 6 guitar "strings") to the Slave MCU. The Slave MCU decodes each packet and stores the appropriate values into the appropriate positions in the userChordN array (the variable used to represent the current chord being played by the user).

To test the SPI communication between the two boards, a simple spi.c code was written. Two integer values from the Master MCU are transfered to the Slave MCU. The transfer process is monitored on hyperterm via UART such that it is possible to see what is being transfered from the Master MCU and what is being received by the Slave MCU. Successful transmission and receipt of the two integers indicates proper hardware quality and setup.

We implement the SPI interface by including SPI_MasterInit() and SPI_MasterTransmit() routines on the Master MCU. Similarly on the Slave MCU, the SPI_SlaveInit() and SPI_SlaveReceive() routines are implemented.

[back to contents]

Block Game

A flowchart for our implementation of the Tetris game is shown below. It includes the major functions and variables used on the Slave MCU. The variables userPath and naturalPath hold the respective possible future movement. The validity of userPath is determined by checking if userPath (left, right, or rotate, in addition to downward gravity) collides with the ground topology of past stationary blocks. This is accomplished by storing and checking a position matrix of 10x20 which holds either 0(empty position) or 1(occupied position). Similarly, the validity of naturalPath (downward gravity only) is also verified by this collision test. The code for video generation is recycled from lab #3, with modifications to draw solid blocks from coordinates in a 10x20 array (as opposed to just an x-y coordinate point).

Other important variables include:

Similar to a standard guitar chord chart, our implementation features up to six numbers that represents the chord to be played. A string without a number means the string should not be strummed. A string with a number represents which fret should be held while that particular string is strummed. For example, our implementation of a C major chord would be:

A standard guitar chord chart for C major would look like:

[back to contents]

Guitar Controller

User Inputs Reading
1. getFret() writes 0 to the vertical lines (PORTA) of the key pad one at a time (one string at a time), read all the horizontal lines (PORTC), and generates fret push information.
2. matchbut(key) is called by getFret(), it translates an 8 bit char to a number from 0 to 5. It returns 0 if no push is detected or more than one frets on the same string have been pushed (considered invalid), and it returns 1~5 when one of the 1st~5th frets has been pushed.
Valid fret push is defined as: On each string, at most one of the 5 frets of each string is pushed.
3. getStrum() reads input IR sensors (from PIND.2 to PIND.7, each bit representing inputs from IR sensors, "1" if infrared light is covered , i.e., a corresponding “string” has been strum)
Implementation of Karplus Strong Algorithm
1. gnrSound() prepares the runTab and other parameters to run in Timer1 compare IST, after input reading has completed. In this function, noise base delay table is built, its index is reset, and countdown timer for string sound duration is set and decremented.
2. TIMER1 compare ISR does the key Karplus Strong Algorithm averaging procedure of the delay line of a proper length, if a certain string is strum and a certain fret on this string is pushed. The delay table filters waves of different frequency and gradually become tables of constants, resulting in constant OCR0A and silence at the output.

[back to contents]


Execution and Performance

Our entire system runs very well. There are no artifacts on the screen (we kept the memory on the tetris MCU to 96.4%), and the guitar sound is quite real. Our guitar sounds great, feels great, and serves as a really unique controller to our tetris game. It is quite responsive, and easy to use. As expected, the SPI interface was implemented quite well, providing quick and accurate data transfer from the guitar MCU to the tetris game MCU.

[back to contents]


Our hardware is very safe. Physically speaking, all edges have been sanded down to prevent splinters and to increase the ergonomics of the guitar. We made the fret board a good distance from the strum board such that the user would not accumulate muscle stress leading to carpel tunnel syndrome or any other muscle disorders.

[back to contents]


Our product does not have any wireless compoenents and thus does not purposely transmit signals through the air. We have not tested the magnitude of any signals created by our devices that may cause intereference, but we do not hope, nor do we expect to find any signals that may cause any disturbances. On the other hand, our speakers are not shielded from GSM-band frequencies, and thus putting your GSM-band mobile near the speaker cables will surely produce unwanted sound from the speakers.

It is, however, observed that the hours spent in working on and playing Guitar Blocks will surely interfere with exam preparations.

[back to contents]


Although this game may seem to have a steep learning curve, it's actually not that difficult if you decide to give it a try. Level 1 has a really slow falling-block speed and allows the user to get accustomed to the simulated guitar, while learning the fingering for the chords. Even though the guitar feels nice, it may help to use a neck strap.

The screen we are presenting on is rather small: a 7" CRT monitor. The signal is very clear, but ideally a larger screen would be prefered to reduce eyestrain. Furthermore (this one's out of our control), the curvature of the CRT monitor is noticable to the point that it is sometimes confusing as to which column the falling block is actually in.

[back to contents]


Meeting Expectations

Our project met all the goals we had in the design phase. Our infrared and push-button guitar sounds like a real acoustic guitar, it's in-tune, has fingering positions identical to a real guitar, and functions as a great, educational tetris controller.

[back to contents]

Future Improvements

The tetris game would be so much more if we had more memory. This can be solved by implenting a more efficient system of storing the 2-D position array. Theoretically, we only need to store 200 bits in our 2-D position array. Currently, we are using

Also to save memory, we could use the wide-screen format to lower the (vertical) raster level. This would give better game performance and would be better suited to modern television sets. With more memory, a tetris implementation in color would seem posible, given that we also revamp the video generation.

In terms of guitar hardware, it would be more realistic if the push buttons were a distance away from each other, comparable to that on a real guitar. Although the infrared system worked well and was pretty cool, the omission of actual strings adversely affected our product in terms of realisitc simulation.

[back to contents]

Meeting Standards

We met all the standards we aimed to meet.

[back to contents]

Intellectual Property Considerations

As strong supporters of open source code, we recycled code from lab. Recycled code includes:

  • UART implementation by Joerg Wunsch, distributed from ECE4760 website
  • Video code template by Shane Pryor, distributed from ECE4760 website
  • Guitar chords and chart images, from Guitar Chords Magic at
  • Website HTML/CSS header code from
  • [back to contents]

    Ethical Considerations

    It's a friendly game of tetris on a friendly simulated guitar. It is a class project with its code written in accordance with the GPL. The product's video output is slow paced and though we did not include a warning screen, we do hope those who are sensitive to video output will take necessary precautions when playing this game. Audio output is designed to accomodate different people by using a standard 3.5mm stereo connection that can be connected to either speakers or headphones. The product's physical dimensions are designed to be ergonomical wherever possible. The distance between the fret board and the strum board is far enough that the user will be comfortable using the device, but not too far such that the board becomes too large to use without damaging nearby objects or the surrounding people. All edges and faces of the guitar's wood are sanded down to avoid splinters while operating the device. We are honest individuals that strive for better results wherever possible. Our product works as stated and most would agree, it is also fun to play.

    [back to contents]

    We has no plans to sell this educational game. It was created purely for the enjoyment of learning in ECE lab.

    [back to contents]

    Appendix A: Commented Code

    [back to contents]

    Appendix B: Schematics

    Fret Board Push Buttons:

    Strum Board Infrared:

    [back to contents]

    Appendix C: Parts & Costs

    Material Cost
    ATmega644 Chip $8
    Protoboard $4
    MAX233 $7
    STK500 $25
    Pushbuttons ($0.25 x 30) $7.50
    Soldering Board (2 x $2 + 1 x $1) $5
    IR receivers & transmitters $0
    Total $56.50

    [back to contents]

    Appendix D: Work Division

    Protoboard for Master MCU Yuan Dong
    Protoboard for Slave MCU Sheldon Xu
    SPI Implementation Sheldon Xu
    Guitar Hardware & Software Yuan Dong
    Block Game Hardware & Software Sheldon Xu
    Project Report and Website Yuan Dong, Sheldon Xu

    [back to contents]

    Appendix E: References & Datasheets


    Vendor Sites

    Borrowed Code/Designs

    Background Sites/Documents

    [back to contents]