Skip to main content
mathew086
Associate
November 10, 2011
Question

Reaction Timer

  • November 10, 2011
  • 3 replies
  • 1285 views
Posted on November 10, 2011 at 15:52

I would like to learn how to control the STR9 to create a reation timer program.  When a button is pressed the unit waits a random time interval (between four and eight seconds) then begins incrementing LEDs on a bargraph display so that they appear to 'rise' upwards. When the user sees the LEDs moving, he presses a 'stop' button as soon as possible - the earlier the button is pressed, the fewer LEDs that are lit. 

Can anyone show an example how to start with this??

Thanks

#reaction #timer #divide-and-conquer
This topic has been closed for replies.

3 replies

Andrew Neil
Super User
November 12, 2011
Posted on November 12, 2011 at 18:41

If you can't solve a problem straight off, you need to break it down & down until you reach smaller sub-problems that you can solve.

This is the standard approach to any project; so best to start learning it now - rather than just ask for ready-made solutions.

Think about the basic elements you're going to need:

  • Sensing inputs - for the button;
  • Driving outputs - for the LEDs;
  • Timing.

You should easily be able to find examples of these elements.

Note that an ARM9 is vastly overkill for this task - so your first simplifying step could be to start on a much simpler processor; eg, an STM8...
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
mathew086
mathew086Author
Associate
November 16, 2011
Posted on November 16, 2011 at 14:40

Thnx andrew... As u mentioned , i divided thw hole task to start with a simple approach

1) Clear  & Initialize LCD

2) Pressing and Initiating  START button.

3) If the START Button is pressed,

Start a timer count down. The counter should start at a random number and when it is reached, the LED have to start blinking in an incrementing way. ( 8 LEDs). This should continue moving back and forth as long as a STOP button is pressed.

3.1) The LED incrmenting should be also time dependant.abt  50ms between each LED step.

4)When the stop button is pressed, It shows the delay in LCD

I will try to go through each step one by one

mathew086
mathew086Author
Associate
November 16, 2011
Posted on November 16, 2011 at 22:48

I have a small question.

for (n = 0xFF; n != 0x00; n >>= 1) 

This line makes the LEDs to start from one corner (P7.0 to P7.7) in an increasing way. How do i adjust this LED blinking with a specified time interval.( random time )??

Also how do i intialize S2 and S3 for a specified task.? I couldnot find the initialization in anywhere.