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 / 16557
16556  |  16558
Subject: 
LeJOS Timing questions
Newsgroups: 
lugnet.robotics
Date: 
Tue, 20 Nov 2001 23:20:14 GMT
Original-From: 
Arnold Vento <avento@austin%nomorespam%.rr.com>
Viewed: 
654 times
  
I know this is probably a newbie question...

I am trying to get the following "line-follower" program (or motors A and C)
to stop after 60 seconds to measure the distance traveled in a minute.  What
would be the simplest way to do this?

All suggestions would be greatly appreciated!

~Arnold~

This the program I am using:

---------------------------------------


import josx.platform.rcx.*;


public class FollowLine
{

   public static void main (String[] arg)
   throws Exception
   {
   Sensor.S2.activate();                  // turn on the sensor light

    Thread.sleep(300);                     // wait for reasonable sensor
values
    int threshold = Sensor.S2.readValue();  // read light-threshold
    LCD.showNumber(threshold);

    while (!Sensor.S1.readBooleanValue())  // loop until robot touched
something
    {
   Motor.A.setPower(7);
   Motor.C.setPower(7);
         Motor.A.forward();                  // go forward for 100
milliseconds
         Motor.C.forward();
         Thread.sleep(100);

           if (Sensor.S2.readValue() > (threshold + 10))   // examine the
black line
           {

     Sound.beep();                   // beeps once
     Motor.A.backward();
            Motor.C.forward();              // turn a little bit left
            Thread.sleep(120);

          } // end if

    } // end while loop

   } // end main()

} // end Class



1 Message 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