Sie sind auf Seite 1von 14

L IGHTS O FF (G AME )

A remake of the famous 1995 game

The rules of the game are very simple. The game consist of a 5 X 5 LED
matrix with a push button(one for each LED). On pressing any of the push
button, the LED associated with it and the four neighbouring LEDs get
toggled. Our aim is to turn off maximum number of LEDs (all if you can) in
minimum presses.

Author : Mohit Lamba


Year : 2nd year

Branch : ECE
Institute : NSIT (Intern)

INTRODUCTION:
Lights Out was a fabulous game launched in 1995 by TIGER ELECTRONICS.
Soon after its launch it became hugely popular. My project Lights Off was to remake
that game.
The game consists of a 5 X 5 grid of LEDs with switches. For the first 10 seconds the
player can choose one of the five stored pattern to initially turn on some of the LEDs.
Then when the pattern is locked the player can start press buttons to toggle the its
associated LEDs as well as the four adjacent LEDs. The aim of the player is to turn
off maximum number of LEDs in minimum number of switch presses.
For the first ten seconds a red LED glows on driver circuit to indicate that the player
can choose the initial pattern. After ten seconds a timer interrupt causes that LED to
blink indiacating that the pattern has been locked.

JUSTIFICATION :
I was completely new to the embedded electronic field and had no past experience
of project of any kind(except for some C/C++ coding). My main intention was to learn
some basic application like LED MULTIPLEXING, use of transistors in practical
circuits, etc. Lights off project conceptually, appeared to me to be fairly simple
project. At the first instant of visualizing only I was able to see how my final
product(roughly) would be with all the top level details. There was no ambiguity in my
mind of what i had to do. At the same place from implementation point of view it
seemed moderately challenging. So considering all this i was very much tempted to
do this project.

Lights Off

HARDWARE :
Following are the components that i required for my project:1. USB connector(1)
2. LM1117 3.3V voltage regulator(1)
3. 10 uF capacitors(2)
4. 1 uF capacitors (3)
5. 10xx OMRON switches (26)
6. 10k, 1k, 330, 220 and 50 resistors
7. 2.7 V zener diode (5)
8. 557b PNP transistors (5)
9. BC337 NPN transistor (5)
10. 20 pin IC connector(1)
11. MO5(3) and MO4(1) connectors
12. Green SMD LED(100) and red LED(1)
13. Female jumper wires(20)
14. Berg strip
15. PCB board- 1.6mm and 0.7mm
JUSTIFICATION OF HARDWARE:

1. MSP430 is powered at 3.3V and the green SMD LEDs are powered at 5V. So
originally the circuit is powered by a 5V supply coming from laptop/ power
bank. For this reason a USB connector has been used.(Refer to schematic)
2. LM1117 buck regulator is used to step down 5V to 3.3V to power MSP430
microcontroller.
3. 10uF and 0.1uF capacitors have been used to remove any ripples present in
supply and decoupling purposes.
4. 10k resistors connected at 2, 3, 4, 5 and 6 at MSP430 (refer to schematic) are
pull up resistors which are used for reading 5 switch columns on the other
board.
5. Five PNP transistors and and five NPN transistors have been used for high
side and low side switching respectively. Because my LED circuit is powered
at 5V and MSP430 provides a high of only 3.3V, they will always drive the
PNP transistors to saturation whether MSP430 pin is high or low. For this
reason 2.7 V zener diodes have been provided to drive the transistors in both
saturation and cut-off state. A link for detailed reading of this has been
provided in references.
6. Three MO5 connectors have been used for driving the five rows and five
columns of LED and 5 columns of switches of the matrix board.
7. MO4 connector has been provided to connect the driver circuit to the MSP430
launchpad for burning the code to the MSP430 chip.

Lights Off

SELECTING APPROPRIATE PNP AND NPN TRANSISTORS:Drop across 1 green led = 2.2V
Current required for appropriate brightness of LED = 2.5 mA
Because with every switch instead of 1 there are 4 LEDs current required = 2.5 X 4 =
10mA
Duty cycle = 1/5
=>Actual current required = 10 X 5 = 50mA
Because in ROW MULTIPLEXING, in a particular column, only one LED is lit up at a
time PNP transistor should be able to provide 50mA of current.
557b PNP transistors have a current rating of 100mA so it has been used in the
project.
But for rows this is not the case. For a particular row at the same time all LEDs can
be lit up.
Hence current to be supplied by NPN transistors = 50 X 5 = 250mA.
However to support even greater brightness, meaning more current, BC 337 high
power NPN transistors have been used which have a current rating of 800mA.

(Schematic of driver circuit and 5X5 LED matrix on next page)

Lights Off

Schematic for
DRIVER CIRCUIT
and
5X5 LED matrix circuit
with switches (next page)

Lights Off

Lights Off

FINDING VALUES OF RESISTORS(USING KVL):-

This is a small cut-out from my schematic which I used to actually calculate the
values of resistors.
FINDING R2

Applying KVL from 5V supply to the ground, the KVL equation is


(Q1 and T1 are in saturation and drop across geen LED is 2.2V)

Hence R2 was taken as 50


FINDING R3

The high from MSP430 is 3.3V. So again applying we get,

Lights Off

(Maximum current that MSP430 can sink/source is 10mA, so I is taken 10mA)


Hence R3 was taken 330 , because 260 is not a standard value of resistors and I
wanted to limit current even below 10mA.
The value of resistor with red LED on the driver board was found similarly using KVL.
Values of all other resistors is mentioned in the schematic and their values were
decided by experience(under the guidance of seniors) and not by KVL.

Lights Off

SOFTWARE IMPLEMENTATION:
For making the schematic and board layout of my project I used CADSOFT EAGLE
version 6.4.0. The reason for using this software are : Its is a open source software so there are no copyright issues involved and
for the same reason a lot of online online support is available.
It has a very high learning curve, it takes only a day to become familiar and
start using the various features of the software. IT ELLEGANTLY DOES
WHAT IT IS MEANT TO DO.
It has a whole variety of the various devices one can imagine to use in ones
project.
Many companies have readily provided the footprint of their devices. So
finding a device and its corresponding footprint was not an issue. If not
present by default, as mentioned before, there is a lot of online support.

The code to be burned into the MSP430 chip was written in CODE COMPOSER
STUDIO version 5.5.
It is the software that TI recommends for its chip, so I went with them without making
any further considerations.

TESTING:
Testing 5X5 LED matrix board

As per my schematic the negative terminal of all LEDs belonging to a row are
connected. Similarly the positive terminal of all LEDs belonging to a column are
connected.
Test 1:
First I set the multimeter to continuity mode.
So now if I touch the black lead of multimeter to the negative of any LED of a row
then that negative supply is provided to all the LEDs of the row. So if one by one, I
touch the red lead of multimeter to different columns, keeping the black lead contact
fixed, the LEDS of that row and that column should light up. I made sure that only
red lead contact is changed every time.
Same procedure was applied for rest of the rows.
Many a times LEDS dint lit when they were expected to. There were the only
possible reason of error :1. Two copper tracks were getting short due to soldering where clearance was
very little. This was taken care by removing excess solder by continuously
rubbing with a pointed object like compass needle.
2. Too little solder was applied that proper connectivity was missing. Or
soldering was not done at all at some places.
Lights Off

3. The 5x5 LED matrix board is a double sided board so 0.7mm PCB board has
been used. But this made the copper tracks very vulnerable to get cut at
many places. These cuts had to be identified by closely examining the board
both by eyes and multimeter. Wherever some cuts were suspected jumper
wires were soldered and finally continuity was tested using multimeter.

After this test I was sure that all rows and columns are connected properly.

Lights Off

10

Test 2:
NOTE: This test is optional. There is no need of this test if everything worked
properly(or was rectified) in TEST 1 only. I did this test only to help myself accurately
pin point where the fault in my board was.
In this test rather than keeping the black lead(of multimeter) fixed and moving the
red lead, we just do the opposite. Everything else is same.
TEST1 corresponds to ROW MULTIPLEXING and TEST2 corresponds to COLUMN
MULTIPLEXING.

Lights Off

11

Test 3:
Now that all the LEDs were working properly it was time to test whether the MSP430
would read the switches or not.
I have used row multiplexing for both LEDs as well as the switches. As TEST1 had
already been performed I assumed that all switches in a row were well
connected(because all discontinuities in the rows were rectified).
So in this test I concentrated on whether all switches in the same column were
connected or not. This part was easy. I simply put my multimeter in continuity mode.
Then put any lead to one of the switches and moved the other lead one by one to the
other switches in the column. Wherever multimeter dint produce sound one of the
three problems as mentioned above were there.
After these three tests I was sure that now my 5x5 LED matrix board with switches
was perfectly fine.

Testing the driver board:-

Test 4:
In this test my aim was to see whether 5V was coming from the USB connector or
not and whether LM1117 was stepping down 5V to 3.3V.
First via laptop and USB cable, board was powered up. Then the black lead of
multimeter was touched with the ground of the LM1117 and the other with the
remaining two terminal.
Initially voltage reading was 0.00V !!!!! And the LM1117 got very very hot that one
could not touch it.
Seniors guided me that this indicated a short. The same three problems as
mentioned in TEST1 were searched for and removed appropriately.

Test 5:
Now it was time to put everything together and do an integrated test.
The two boards were connected using 15 female connectors and initially a simple
code of LED multiplexing was burned into the MSP430 chip. This proved that my
5X5 LED matrix board and the driver circuit were perfectly fine.
Then a code to simply toggle a LED by reading a switch in pull up configuration was
burned. This made sure that even the switches were soldered correctly.
It also confirmed that the code logic was also correct as the final code, till some
extent, is just merging together both the codes( although a lot more complex
because now both LED and switch multiplexing had to be done together ).

Lights Off

12

People who made it possible :


First of all I would like to thank Prof. Dhananjay V. Gadre for organizing the TI
University Program workshop funded by Texas Instruments. I had heard of various
other embedding system workshops from my friends. But after completing this
workshop, its very clear, its best of all of them. Even my friends readily agree to this
fact. They say, Wow, you have attended a very nice .
His theory lectures in the mini auditorium, I think, if not more but surely equally
valuable as my working project. But there is one thing which make those lectures
more important. My project can be replicated with major improvements and repeated
many times. But those lectures on ASIC, RISC vs CISV, UART, high side and low
side switching, etc are rare. They cannot be replicated. Ill miss them more.
Next I would like to thanks all the seniors at CDET, saral sir, ritika maam, ishaan sir
and nikhilesh sir.
Ritika maam taught me MSP430 G2553 LED blinking, PWM, ADC, etc.
Saral sir, literally, visualised the entire project for me. From schematic to board file in
eagle, from drilling and soldering to rectifying the board, everything was guided by
saral sir. His efforts in making the double sided board are exceptional. He really
tolerated me throughout the hardware issues with a smile.
Next I would like to thank Ishaan sir. The really complex part of merging the two
logics (I mentioned before), of simultaneously doing LED multiplexing and switch
multiplexing, was guided by Ishaan sir. His unique idea of reducing the variables
using left shift(<<) and right shift(>>) operators was not less than a breakthrough in
my project.
I cannot also forget the overall guidance of nikhilesh sir.
And finally I would like to thanks all the volunteers, Gaurav tyagi, ketan, kshitij,
saddam and many more for everything else. They helped very nicely in making the
board, grinding, drilling, getting the components, etc.
I cannot imagine my project to have progressed an inch without there help and
guidance.

Click on the link to for a video of my project:


http://youtu.be/me6P4XTSXnQ

Lights Off

13

Refernces :1. For learning how to code in MSP430, especially GPIO interrupts and polling, I
used the book,
MSP430 Microcontroller Basics
AUTHOR - John H. Davies
ISBN - 978-0-7506-8276-3
PUBLISHER - Newnes
EDITION 2008
2. To study in detail how high side and low side switching works, especially
when zener diode is used refer to following link
http://www.edn.com/design/systems-design/4431122/Zener-level-shifterdrives-high-side-switch
by Dhananjay Gadre & Nidhi Sharma on June 16, 2014

Lights Off

14

Das könnte Ihnen auch gefallen