Subject:
|
Straight moving with only one rotation sensor
|
Newsgroups:
|
lugnet.robotics.rcx.nqc
|
Date:
|
Thu, 10 Jun 2004 00:11:40 GMT
|
Viewed:
|
6468 times
|
| |
 | |
Hi
I saw in the LEGO Mindstorms Web Page that many people made their robots with 2
motors go straight using one rotation sensor on each wheel and stopping the
correct motor until both sensors were equal.
I got Ultimate Accessory Set as a present some months ago and I wanted to make
robots go straight using only one rotation sensor. I made it using a
differential.
Here is the unfinished NQC program for it:
#pragma init myinit
void myinit()
{
SetPower(OUT_A+OUT_B+OUT_C, 7);
SetDirection(OUT_A+OUT_B+OUT_C, OUT_REV);
}
task main()
{
SetSensorType(SENSOR_3, SENSOR_TYPE_ROTATION);
SetSensorMode(SENSOR_3, SENSOR_MODE_ROTATION);
int sensorval;
while(true)
{
sensorval=SensorValue(2)/2;
if(sensorval > 0)
{
On(OUT_A);
Off(OUT_C);
}
else if(sensorval < 0)
{
Off(OUT_A);
On(OUT_C);
}
else
{
On(OUT_A + OUT_C);
Wait(10);
}
}
}
LMKWYT
--
- Nicolas Alvarez
nicoalvar0.no.spam@hotmail.com
|
|
Message has 3 Replies:
6 Messages in This Thread:       
  
  
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|