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 / 1400
1399  |  1401
Subject: 
Re: Need help with NQC
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Thu, 4 Apr 2002 03:31:54 GMT
Viewed: 
3617 times
  
"Russell Newman" <victoreden@netzero.net> wrote in message
news:GtLuCA.38p@lugnet.com...
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

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 of a half a second.  Is that
enough?

Kevin


#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(); file://Used to set up the sensors and tasks
while(true); file://A repeat forever loop
  {
  bumper_check(); file://Checks bumpers for collisions and turns
  ir_check(); file://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); file://Turns on the motors to go straight
start send_ir; file://Starts the task that sends out IR light
}

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

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

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



Message is in Reply To:
  Need help with NQC
 
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 (...) (23 years ago, 26-Mar-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