Shop OBEX P1 Docs P2 Docs Learn Events
Reaction timer — Parallax Forums

Reaction timer

obdiobdi Posts: 1
edited 2011-10-01 21:04 in BASIC Stamp
Hello,
i need help :( i must program a reaction timer for my university but i cant program the code :(
Here is the task:
Press and hold the pushbutton to make the light turn red. When the
light turns green, let go of the push button as fast as you can��
The program should output the use the instructions and, after the test is
complete, the time (in milliseconds) it took for the user to react to the green
light.

Can you help me?

(sorry for my bad english)

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-10-01 15:01
    We cannot write the program for you. You will have to learn enough to write the program yourself. We can help you by pointing you to various manuals and examples. I'm assuming that you are using a Basic Stamp. If so, download copies of the "Basic Stamp Syntax and Reference Manual" and the "What's a Microcontroller?" tutorial from this webpage under "Basic Stamp Documentation" and "What's a Microcontroller? Resources". The tutorial will show you how to use pushbuttons and LEDs with a Stamp. I don't think it discusses explicitly how to use a bidirectional red/green LED, but that's not a big deal if you're using one of those as opposed to a common cathode or common anode red/green LED which isn't really different from using separate LEDs.

    You haven't said how the program is supposed to output the user instructions. If you're using a Basic Stamp, is this supposed to appear on the attached PC's debug window or a separate display of some kind?

    Usually timing on this order (milliseconds) is done by using the time it takes to do a couple of statements in PBasic and counting the number of times those statements can execute before the end condition is met, then adjusting for the time that it takes for one time through the loop. This website has lots of information on timing with a Basic Stamp. Use the "app-notes" link. Ask more questions as you go along.

    Generally, the more information you provide and the more specific you can make your questions, the more information you will get in return. When posting code, use the Go Advanced button and attach your source code files to a message. Do not use cut and paste to include code with your messages.
  • ercoerco Posts: 20,256
    edited 2011-10-01 19:26
    That's a great first project, you can figure out how to do that within the first few chapters of "What's a Microcontroller". Per Mike, we can't do it for you, but we're eager to help once you've shown some real effort.
  • LeonLeon Posts: 7,620
    edited 2011-10-01 21:04
    A random delay would be a good idea.
Sign In or Register to comment.