Waitfordarker inventor equivalent code?

This is where you talk about the RCX software itself, installation issues, and programming talk.

Moderator: roger

New User
Posts: 1
Joined: Fri May 25, 2007 7:59 am
Location: Australia

Waitfordarker inventor equivalent code?

Postby rauli » Fri May 25, 2007 8:18 am

I have this crane like robot. Its grip opens then lowers to the floor and at first it is supposed to locate the dark area on the left, reset the angle sensor then move towards the right to find the second dark area. This is the initalization phase. The problem is with detecting the dark area on the paper, so far I have had it just go past it or immediately seek right to the second dark spot as soon it hits the ground. My relevent methods and code are ask follows:-

in the main() method
// Initialise Light Sensor on port 2

another method, meant to seek the first dark area on the left
public static void LocatePickupSite() {
WaitforDarker(); // This is another method in the single class file
ResetAngleSensor(); // This is another method in the single class file

WaiforDarker() method below which is not working
lightlevel is a global variable declared as private static int lightlevel = 0; before the main method along with the other variables to store angle sensor values.

public static void WaitforDarker() {
lightlevel = Sensor.S2.readValue();

// this reading (lightlevel) is taken immediately after the light sensor against the ground hits the white part of the paper when the arm falls down and before it turns left towards the first site.

while (lightlevel >= Sensor.S2.readValue()) {

I have the Sound.beep(); in there just as a debug trick to tell if the loop is occuring which it does and never exits with my current code.

I am worried that the PCT means percentage and is not compatible as an integer for the purposes of comparing with another integer

After it finds the pickup site black area this method below is invoked which again would not work because the WaitforDarker() method is not working and this method does not start because it keeps looping in the WaitforDarker() method indefinitely.

public static void LocateDropoffSite()
throws Exception {
WaitforDarker(); //This is another method in the single class file

What am I doing wrong? the waitfordark() method I made does not work. I have fiddled with it for quite some time and am not making progress. does anyone have java code that is equivalent to the Waitfordarker function in robolab inventor?


Return to “RCX Software”

Who is online

Users browsing this forum: No registered users and 0 guests