This is a great game to test your skills.

Step 1: INTRO

This project has been adapted from an experiment by John Ridley Stroop, who published his work in 1935. Basically it is a "trick." It is a trick in that you are required to answer a question at a "second level of thinking."
In our test we have three tri-coloured LEDs and below each is a push-button.
When a LED illuminates, your immediate response is to push the button below the LED.
But this is not the requirement.
The LED will illuminate as one of three colours. Red, Orange or Green.
You are required to push the first button for red, the middle button for orange and the third button for green.
In other words you have to divorce yourself from the urge to push the closest push-button and work on the colour-requirement.
Obviously you will become more-adept at this over a period of time but the most important results will come from the first few attempts.
That's why it will be interesting to have your friends take a test.
The "Stroop effect" has been used to investigate the psychological capacities of a person. In fact it introduces capabilities that have never been investigated before. Although I don't believe in anything to do with psychology, this test is considered to measure selective attention, cognitive flexibility and processing speed. About the only word I understand is "processing speed" and that's how our game works. It runs for 20 seconds and gives a score on the 7-segment display.
You are required to get as many matches as possible in 20 seconds.
The game comes on by displaying the letters "S-t-r-o-o-P" on the 7-segment display and then sits ready for your first try.
The single digit display can actually display up to 99 as it flashes the tens digit first and then the units. It repeats this three times and turns off, ready for the second game. Push any button to start.

Step 2: The CIRCUIT

See Circuit below and see the .asm and .hex files by clicking on the box above: "View all steps on one page."


You can build the circuit on any type of Proto board or design your own PC board.
Use 3 - AAA cells and not button cells as button cells do not have low enough impedance to keep the voltage high when all the LEDs are illuminated and the chip hic-cups and flashes the display.

Step 4: The PROGRAM

The program has been kept simple to make it easy to understand. Very few Boolean expressions have been used as they take a lot of understanding and "working out" as to the the outcome of the instruction.
We note that a simpler program was written in "C" and it failed to compile into the 1024 memory locations, so I don't know how the inefficiency of higher-level programming would relate to this project.
In any case, we have used the 35 instructions that come with the chip and this makes fault-finding very easy as you know the fault lies in the code you have generated.
As long as you only introduce a small amount of code at a time, you will be able to gradually get a program up-and-running.
The interesting feature of the program is the overall timing. The micro is counting in the background via timer1 and this consists of two files (registers) capable of counting to 65,536. A prescaler has been added to increase the count to 524,288. This is about half a second.
When the timer overflows, the program-execution is interrupted and the micro goes to location 4 (called the Interrupt location where it finds an instruction to go to a sub-routine called: "isr." At isr, another file is decremented (_20Secs) thirty-nine times and this produces the 20 seconds duration for each game.
(Point to remember: Timer0 does not produce a long delay, so Timer1 has to be used).

The buttons are detected by charging the 100n and waiting 20mS to see if the capacitor has discharged. We know the cap will discharge in less than 8mS if a button is pushed.
The program now knows if a button is pushed or not.
It makes a second pass, if a button is pushed, to work out which button has been pressed.
The first button will discharge the cap in less than 2mS, the second button will discharge the cap in less than 4mS and the third button will discharge the cap in less than 8mS.
The program now performs a 1mS loop, looking for a LOW on the detecting pin.
It will exit with a value of 1-8.
The program now decrements the count file and and if it is zero after one or two decrements, button 1 has been pressed. It continues with decrements until it finds the button.


The most difficult thing to produce on a computer is a random number.
You can combine and XOR various files or use a table. but nothing generates a truly random result.
We have used the "waiting time" when a player waits to provide an answer and this generates a new random number, while the program is actually using a previously generated number for the play in progress. That's why the random number has to be generated in a sub-routine called "Create," and this number is passed to the Random Number file for use in the next try.

The program contains a number of very important subroutines that you will be able to "cut and paste" for projects in the future.

Step 6: MORE

For more details on modifying the program and burning the PIC chip, see Talking Electronics website and click on Elektor,EPE,Silicon Chip in the index.
You can find details of: PICkit-2 and Adapter connected for In-Circuit Programming at this link.

Step 7: Parts List

Stroop Parts List
Cost: au$25.00 plus $7 postage
Kits are available from talkingelectronics.com

7 - 22R SM resistor
6 - 82R SM resistor
1 - 2k2 SM resistor
1 - 22k SM resistor
1 - 47k SM resistor
1 - 100k SM resistor

2 - 100n SM capacitors

14 - Orange SM LEDs
3 - tri-coloured LEDs
1 - SPDT mini slide switch
3 - mini tactile push buttons

20cm fine enamelled wire
30cm - very fine solder
1 - 18 pin IC socket
5 - machine pins
1 - PIC16F628 chip (with Stroop routine)
3 - AAA cells (do not use button cells
- they produce false operation)
1 - Prototype PC board

Pre-programmed PIC16F628 micro with Stroop routine $15.00 plus $5.00 post
from talkingelectronics.com

Step 8: THE GAME

The game is played by switching the project on and seeing which colour is illuminated.
Press the first button if the colour is RED, the second button if the colour is Orange and the third switch if the the colour is GREEN.
The aim is to get as many correct in 20 seconds.
The score appears on the 7-segment display. The display flashes the tens digit and then the units. It then blanks for 2 seconds and repeats the number. It does this 3 times then turns off.

Step 9: Files

Click on: "View all steps on 1 page" to see the .pdf of the whole article including the program and .asm, .txt and .hex files
Here's the stroop game in video : http://www.youtube.com/watch?v=zfXAh3MOL9w <br> <br>thanks! <br>marC
Is pic16f628A compatible with that?<br><br>thank you!<br>marC:)
PIC16F628 or PIC16F628A can be used
What is the difference with those 2? and can i use ANY Pic16f628 into pic16f628a?<br><br>thank you Colin! :)<br>marC:)
The only difference is the way the code protection-bits are set to prevent others hacking into the chip to reach the program.
so the code for a PIC16F628 is ALWAYS compatible with the pic16F628A chip?<br><br>thank you Colin!<br>marC:)
Thank you Colin! :)
Missing a few pictures?
All the photos have been included in the article. There are no step-by-step instructions as the project is really only suitable for expert constructors as the components are all surface-mount.
But if you include step-by-step images, you help others <em>become</em> capable of making it.<br/><br/>Else, what's the point? &quot;Here's an instructable you mere mortals cannot make&quot;?<br/><br/>In addition, the inclusion of pictures of your make shows that you <em>have</em> made it...<br/>

About This Instructable




More by colin55:STROOP GAME 
Add instructable to: