3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Arduino and Touchpad Tic Tac Toe

Arduino and Touchpad Tic Tac Toe
Or, an exercise in input and output multiplexing, and working with bits.  And a submission for the Arduino contest.

This is an implementation of a tic tac toe game using a 3x3 array of bicoloured LEDs for a display, a simple resistive touchpad, and an Arduino to tie everything together.

To see how it works, check out the video:



What this project requires:

Parts and consumables
One perf board (or strip board)
Nine bicoloured LEDs, common cathode
Nine identical resistors, in the 100-220 ohm range
Six identical resistors, in the 10kohm - 500kohm range
One single pole, double throw switch
A bunch of header pins
A bunch of electrical wire
One small square sheet of transparent acrylic, ~ 1 mm thick, 8 cm on the side
Clear sticky tape
Heatshrinks (optional)

All of the above are quite common items, total cost should not exceed USD$20.

Tools
One Arduino setup (Arduino Duemilanove, Arduino IDE, computer, USB cable)
Usual electrical tools (multimeter, solder solder gun, wire snips, wire cutter)

Everything Arduino related can be found at http://www.arduino.cc.

On with the build!

 
Remove these adsRemove these ads by Signing Up
 

Step 1Wiring up the LED matrix

Wiring up the LED matrix
«
  • LEDcrossbar1.png
  • LEDcrossbar2.png
For an LED to light, both its leads must be connected.  If we were to dedicate a pair of pins to each of the 18 LEDs (9 red, 9 green), we'd quickly run out of pins on the Arduino.  However, with multiplexing, we'll be able to address all the LEDs with merely 9 pins!

To do this, the LEDs are wired up in a crossbar fashion, as shown in the first figure.  The LEDs are grouped in columns of threes, and their cathodes are grouped in rows of sixes.

By setting a particular anode line high, and a particular cathode line low, and having a high impedance on all the other anode and cathode lines, we can select which LED we want lit up, as there is only one possible path the current can take.

For instance, in the second figure, setting the green anode 1 line high, and the cathode 1 line low, the bottom left green LED lights up.  The current path in this case is shown in blue.

But what if you want to light up more than one LED on different lines?  We'll use persistence of vision to achieve this.  By selecting pairs of LED lines very very quickly, it gives the illusion that all the selected LEDs are lit at the same time.

« Previous StepDownload PDFView All StepsNext Step »
59 comments
1-40 of 59next »
Feb 11, 2012. 11:13 AMthepoynt says:
Any suggestions on how to test the touchpad by itself? I haven't built any of the rest of the project, and I'd like to make sure this part works before going on.

btw, great project idea - I'm enjoying building it!
Dec 25, 2011. 9:41 PMrobot1398 says:
made the keypad and got it to work.........
Nov 23, 2011. 9:35 AMbmorgan6 says:
I have a question where can i find the switch you ask for and does it have to be a throw switch?
Nov 7, 2011. 12:16 AMKeanan says:
I notice in the code it has i % 3. I assume this is for the double anode/ one cathode for the LEDs you are using. So how would one change the code to accommodate for dipole LEDs instead of tripole?
Nov 7, 2011. 2:12 AMKeanan says:
So then, what must be changed for 2 lead LEDs to work instead of the 3 lead ones?
Oct 17, 2011. 2:31 AMaldrome says:
Hi, I really like your idea!! And i was wondering if it is really importat that The red and green anode lines go into the PWM pins of the Arduino, I mean, why do they have to be PWM?, can they be the normal pins like number 2 or 13? It's because I'm trying to mix this with another idea I have.

Thanks for everything.
May 5, 2011. 2:34 AMjwoo2023 says:
can I use arduino uno?
May 12, 2011. 12:21 AMjwoo2023 says:
thanks for the info
!
Feb 4, 2011. 7:33 AMskylen says:
So it sounds like this touchpad matrix uses capacitive sensing, rather than resistive touch operation. When a finger is placed on the intersection of a row wire and a column wire, it increases the capacitance between the wires, causing the LOW level on the column wire to couple more strongly to the row wire, resulting in the touched row dropping in voltage more quickly than if it were not pressed.

Example: ChaN's Simple Touch Sensor
Feb 8, 2011. 12:17 PMartecx says:
I've problems with downloading the .pde files.
any solution to download them proper?
they all got a .tmp extension
Nov 13, 2010. 11:16 PMwareneutron says:
you have a great idea in that game
Sep 20, 2010. 9:33 AMmaewert says:
I really enjoyed this instructable.

A few comments however.
1.  I see that the random number sequence is always the same.  You need to add a random seed.
2.  The computer is very easy to beat since it does not take a winning move or try to block the user's winning moves.  These changes make the computer more difficult to beat but not impossible, so playing is still fun.

I updated the code to correct these two items and to make it work without your special hardware (i.e. you can play with a standard Arduino and a serial monitor or with your led touchpad).

This could be the start of the old 'tic-tac-toe playing chicken' seen in some county fairs where the person plays against the chicken.  When it is the chickens 'turn' the door to the chicken food is opened and the chicken appears to be thinking then pecks a selection.  This works so long as the person can't see what the chicken is packing at and assumes it is a similar display/keyboard they are presented with.  Very funny seeing kids getting beat by a chicken!

If there is community interest we could always make the 'impossible to beat the computer' version but where is the fun in playing that?  :-)

Best Wishes
Sep 10, 2010. 7:58 PMAdi0005 says:
This is the first time I am using bicoloured LEDs. So I was wondering if you could include a diagram of led matrix of arrangement of the bicoloured Leds.
Thanks
Aug 18, 2010. 10:28 PMkristiansmic says:
This will be my first project with arduino. It don't looks hard. Can i don't use ''touchpad'' but just buttons in matrix?
Jun 9, 2010. 11:17 AMmikeyx says:
Very good idea.
Apr 20, 2010. 12:13 AMelectronics4you says:
Dear Author,

Had a few questions popping in my head..! Since Arduino is popular BECAUSE it's an open-source platform, can we say the same about all the instructables out here using the arduino board? Who owns the IP..the guys at instructables.com or the individual author? What if I were to publish an article in a mag about this touchpad tic-tac-toe..whose permission do I take..if at all I need one?

Thanks. Hope to hear from you!
Apr 16, 2010. 2:52 AMkeven says:
is this needed
when I ran this in circuir wizard it was the only way I could get it to work
what is your suggestions
keven
Apr 14, 2010. 1:14 AMkeven says:
http://yfrog.com/6rcircuitdiaj
here is the link
can you tell me why I can't attached it in instructable ?
thank you for your persistance
Apr 13, 2010. 2:30 PMkeven says:
Hi its keven again
i have tried to attached the image to this email and for some reason it will not
I haved uploaded it to ImageShack
file name is circuitdia.jpg
please see if you can see it
the circuit is a simplfied version of the actual one
each led in the circuit represents 24 led with resistors and a 12v+ power supply
I hope this helps
keven
Apr 10, 2010. 9:52 PMkeven says:
Hi again
it's Keven
I have been trying to teach myself in trying to control 12volt led circuit through the Arduino without success
can you help
I have included the circuit I have been trying to use and still with no avail
where am I going wrong?
I would appricate any help you can give
i will wait for your reply
keven
Apr 12, 2010. 12:39 AMkeven says:
Thank you for your responce
I wil wait for your reply
I have I hope attached a image of my circuit  
keven 
Apr 1, 2010. 11:38 PMelectronics4you says:
Hi,
I've been working on this project lately..I'm a little confused about the touchpad wiring..when the fingertip touches an intersection point, should the two grids (one row and one column) indicate continuity with the multimeter? If the intersections are insulated at all times with the clear tape, how will the finger touch cause the conduction??
Please help!
P.S: great instructable, otherwise :)

1-40 of 59next »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
8
Followers
3
Author:origamiwolf