To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 23866
23865  |  23867
Subject: 
Re: light sensor, 3 secs
Newsgroups: 
lugnet.robotics
Date: 
Tue, 12 Apr 2005 07:34:26 GMT
Viewed: 
1153 times
  
You could base the program on a loop. The RCX has a built in timer -
and you can read this in NQC -
http://www.informatik.uni-kiel.de/inf/von-Hanxleden/mindstorms/Programmierung/NQC/timers.html.
The loop checks the state of the sensors, and how long they have been
pressed. if the sensor is no longer active - go to a "loser" routine,
and if the time has expired do the victory routine, otherwise, stay in
the loop and continue checking and making random movements.

You may want to have another timer in the loop set up to do the random
movement - since you dont want to move every time round (it may still
be moving) - this also minimises the chance of the loop ignoring a
"hit" or "miss" because it is in other gubbins of the loop and not
checking the sensor.

I hope this helps
Danny
--
http://orionrobots.co.uk - Build Robots

On Apr 12, 2005 12:41 AM, roc <lego-robotics@crynwr.com> wrote:
i am working on this silly game where you have to "shoot" a simple
pivoting mechanism (it moves like a metronome) with a light sensor on
top of it, using a laser pointer. you win if you manage to keep the
laser pointer in the light sensor for more than, say, 3 seconds. so the
robot will try to avoid that and dodge the beam by moving randomly and
at different speeds. i am a NQC newbie and i cant figure out the way to
make the program check if the light sensor is "hit" for 3 seconds.
any help will be really appreciated.




Message is in Reply To:
  light sensor, 3 secs
 
i am working on this silly game where you have to "shoot" a simple pivoting mechanism (it moves like a metronome) with a light sensor on top of it, using a laser pointer. you win if you manage to keep the laser pointer in the light sensor for more (...) (19 years ago, 11-Apr-05, to lugnet.robotics)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR