hi there , im still new to nxt programming …im doing project on robots with two sensor light moving on white line on a black surface …i try to figure the right source code but i still cannot find the solution … so , i try to find it out using internet. I found one but the codes are in rbt format .can anyon help me with this … i really need it
#include<reg51.h>
sbit m0 =P2^0;
sbit m1 =P2^1;
sbit m2 =P2^2;
sbit m3 =P2^3;
sbit s1 =P1^0; //sensor1
sbit s2 =P1^1; //sensor2
void main()
{
while(1)
{
while(s1==1&&s2==1) //straight
{m0=1;
m1=0;
m2=1;
m3=0;
}
while(s1==1&&s2==0) //right
{m0=0;
m1=0;
m2=1;
m3=0;
}
while(s1==0&&s2==1) //left
{
m0=1;
m1=0;
m2=0;
m3=0;
}
while(s1==0&&s2==0) //stop
{m0=0;
m1=0;
m2=0;
m3=0;
}
}
}
Hi djkalai,
Welcome to the RobotShop Forum. There should be sample code available on the CD included with your NXT for how to create and code an line following robot. There are many projects online which describe exactly how to make a line following robot and provide sample code. Use the keywords NXT LINE FOLLOWER CODE in Google. One website details how to use RBT formats.
Hope this helps,