Subject:
|
Straight moving with only one rotation sensor
|
Newsgroups:
|
lugnet.robotics.rcx.nqc
|
Date:
|
Thu, 10 Jun 2004 00:11:40 GMT
|
Viewed:
|
4768 times
|
| |
![Post a public reply to this message](/news/icon-reply.gif) | |
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: ![You are here](/news/here.gif) ![](/news/246.gif) ![Re: Straight moving with only one rotation sensor -Sandy Johnson (10-Jun-04 to lugnet.robotics.rcx.nqc)](/news/x.gif) ![](/news/46.gif) ![Re: Straight moving with only one rotation sensor -Danny Staple (10-Jun-04 to lugnet.robotics.rcx.nqc)](/news/x.gif) ![](/news/46.gif) ![Re: Straight moving with only one rotation sensor -Nicolas Alvarez (12-Jun-04 to lugnet.robotics.rcx.nqc)](/news/x.gif)
![](/news/x.gif) ![](/news/268.gif) ![Re: Straight moving with only one rotation sensor -Joseph Woolley (11-Jun-04 to lugnet.robotics.rcx.nqc)](/news/x.gif)
![](/news/x.gif) ![](/news/68.gif) ![Re: Straight moving with only one rotation sensor -Nicolas Alvarez (12-Jun-04 to lugnet.robotics.rcx.nqc)](/news/x.gif)
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|