NXT Help

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
moltendaniel
Posts: 2
Joined: 03 May 2013, 12:05

NXT Help

Post 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.
hassenplug
Posts: 346
Joined: 27 Sep 2010, 03:05
Contact:

Re: NXT Help

Post 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
---> Link to lots of MINDSTORMS stuff under my picture --->
moltendaniel
Posts: 2
Joined: 03 May 2013, 12:05

Re: NXT Help

Post 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
h-g-t
Posts: 552
Joined: 07 Jan 2011, 08:59
Location: Albania

Re: NXT Help

Post by h-g-t »

A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
mark1993
Posts: 1
Joined: 11 May 2013, 16:08

NXT software ??

Post 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 :)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests