To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 1384
1383  |  1385
Subject: 
Need help with NQC
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Tue, 26 Mar 2002 23:52:58 GMT
Viewed: 
3364 times
  
I just wrote a program and I can't get it to work. I download it to the RCX
and it just runs its motors. I look at the display and push on the bumper
and it has those little triagles. So it is not hardware because the RCX
reads that the bumper in pushed. I need help! here is the program

#define go_straight() Fwd(OUT_A+OUT_C);
#define back_up() Rev(OUT_A+OUT_C);Wait(75);Fwd(OUT_A+OUT_C);
#define turn_left() Rev(OUT_A);Wait(Random(50));Fwd(OUT_A);
#define turn_right() Rev(OUT_C);Wait(Random(50));Fwd(OUT_C);
int last_value; // Used for IR proximiy sensing

task main()
{
start_up(); //Used to set up the sensors and tasks
while(true); //A repeat forever loop
  {
  bumper_check(); //Checks bumpers for collisions and turns
  ir_check(); //IR proximiy sensing
  }
}

void start_up()
{
SetSensor(SENSOR_1,SENSOR_TOUCH);
SetSensor(SENSOR_2,SENSOR_LIGHT);
SetSensorMode(SENSOR_2,SENSOR_MODE_RAW);
SetSensor(SENSOR_3,SENSOR_TOUCH);
On(OUT_A+OUT_C); //Turns on the motors to go straight
start send_ir; //Starts the task that sends out IR light
}

void bumper_check()
{
if(SENSOR_1 == 1) //Checks for left bumper
{
  back_up();
  turn_right();
  go_straight();
}
if(SENSOR_3 == 1) //Then checks for right bumper
{
  back_up();
  turn_left();
  go_straight();
  }
}

void ir_check()
{
last_value = SENSOR_2; //Stores the value of the light sensor
if(SENSOR_2 <= last_value - 75) //Checks for a high fluctuation in light
{
turn_right(); //turns
go_straight();
}
}

task send_ir() //sends out a bunch of signal 20 times a second
{
while(true)
{
SendMessage(0);
Wait(5);
}
}



Message has 1 Reply:
  Re: Need help with NQC
 
"Russell Newman" <victoreden@netzero.net> wrote in message news:GtLuCA.38p@lugnet.com... (...) RCX (...) In what way is it misbehaving? When backing up, it only backs up for 3/4 of a second. Is that enough? When turning, it only turns for a maximum (...) (22 years ago, 4-Apr-02, to lugnet.robotics.rcx.nqc)

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