View unanswered posts | View active topics It is currently Wed Aug 05, 2020 10:27 am






Reply to topic  [ 1 post ] 
sample nxt program 
Author Message
Rookie

Joined: Mon Mar 28, 2011 5:41 pm
Posts: 4
Post sample nxt program
I wanted to know how can i order to the robot turn left when it does the condition and the next time that it does turn right
This is my program:
//*!!Sensor, S2, soundSensor, sensorSoundDB, , !!*//
//*!!Sensor, S4, sonarSensor, sensorSONAR9V, , !!*//
//*!! !!*//
//*!!Start automatically generated configuration code. !!*//
const tSensors soundSensor = (tSensors) S2; //sensorSoundDB //*!!!!*//
const tSensors sonarSensor = (tSensors) S4; //sensorSONAR9V //*!!!!*//
//*!!CLICK to edit 'wizard' created sensor & motor configuration. !!*//

task main()

{
int i,x;//variable del sensor de sonar
i=0;
while(true) {

x = SensorValue[sonarSensor];
nxtDisplayBigStringAt(25, 23, "%3d", x);
nxtDisplayBigStringAt(25, 45, "%3d",i);
if(x>30) {

motor[motorB]=25;
motor[motorC]=25;
wait10Msec(100);

}

else if(i==0) {

motor[motorB]=25;
motor[motorC]=0;
wait10Msec(100);
i=1;
}
else if(i==1){
motor[motorB]=0;
motor[motorC]=25;

i=0;
}

}
}


Mon Mar 28, 2011 5:53 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.