Page 1 of 1

NXT Help

Posted: 03 May 2013, 12:11
by moltendaniel
alright guys i need a little help. for an assignment for college ive got to program an NXT to move and react with 2 sensors. now normally that would be fine but the software they use is rubbish and causes the code to clash with each other half the time and crash the other. if i try do it in raw code it never works. if anyone can help me make the robot just move forward until it either gets a signal from the touch sensor or gets a signal from the sound sensor it will turn 90 degress to either the left or right then i would be eternally grateful. Everytime i try and do it, it never works so if someone could just make a quick coding of it and copy and paste it on here i will be very grateful to you.

Re: NXT Help

Posted: 03 May 2013, 12:41
by hassenplug
moltendaniel wrote:alright guys i need a little help. for an assignment for college ive got to program an NXT to move and react with 2 sensors. now normally that would be fine but the software they use is rubbish and causes the code to clash with each other half the time and crash the other. if i try do it in raw code it never works. if anyone can help me make the robot just move forward until it either gets a signal from the touch sensor or gets a signal from the sound sensor it will turn 90 degress to either the left or right then i would be eternally grateful. Everytime i try and do it, it never works so if someone could just make a quick coding of it and copy and paste it on here i will be very grateful to you.
1) What software are they using?
2) What software do you want to use?

Steve

Re: NXT Help

Posted: 09 May 2013, 11:41
by moltendaniel
hassenplug wrote:
moltendaniel wrote:alright guys i need a little help. for an assignment for college ive got to program an NXT to move and react with 2 sensors. now normally that would be fine but the software they use is rubbish and causes the code to clash with each other half the time and crash the other. if i try do it in raw code it never works. if anyone can help me make the robot just move forward until it either gets a signal from the touch sensor or gets a signal from the sound sensor it will turn 90 degress to either the left or right then i would be eternally grateful. Everytime i try and do it, it never works so if someone could just make a quick coding of it and copy and paste it on here i will be very grateful to you.
1) What software are they using?
2) What software do you want to use?

Steve
im using bricxcc for the raw coding. i cant remember the drag and drop software the college provides but it is rubbish and never works so thats why im using the bricxcc software. if you can provide some code examples on making the sound sensor work and the touch sensor so i can make them work together i would be very grateful. thank you

Re: NXT Help

Posted: 09 May 2013, 13:29
by h-g-t

NXT software ??

Posted: 11 May 2013, 16:14
by mark1993
Hi there, I want to write a program in robotc NXT that will make the robot to move above a black strip and when it find a white object it remove it from is way and when it finds a black object it by pass it and return back to the black track......help!!. This is my first attempt to write an NXT robot code and this what i have right now.

#pragma config(Sensor, S4, sonarSensor, sensorSONAR)
#pragma config(Sensor, S1, colorPort, sensorCOLORFULL)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
string sColor;
int distance_in_cm = 20; // Create variable 'distance_in_cm' and initialize it to 20(cm).

while(1)
{
if(SensorValue[sonarSensor] > distance_in_cm) // While the Sonar Sensor readings are less than the specified, 'distance_in_cm':
{
motor[motorB] = 20;
motor[motorC] = 20;
}
else if (SensorValue[sonarSensor] < distance_in_cm)
{
switch (SensorValue[colorPort])
{
case BLACKCOLOR: sColor = "Black";
motor[motorC] = -10; // Motor C is run at a 75 power level.
motor[motorB] = -10;
wait1Msec(1000);
motor[motorC] = 360; // Motor C is run at a 75 power level.
motor[motorB] = -360;
break;
case WHITECOLOR: sColor = "White";
motor[motorA] = 1;
wait1Msec(100);
motor[motorB] = 0;
motor[motorC] = 0;
wait1Msec(1000);
motor[motorA] = -10;
wait1Msec(100);
motor[motorA] = 10;
wait1Msec(100);
break;
default: sColor = "???";
motor[motorB] = 0;
motor[motorC] = 90;
wait1Msec(100000);
break;
}
nxtDisplayCenteredTextLine(2, sColor);
wait1Msec(50);
}
}
}



I appreciate your time and help :)