I' starting to learn NXC (slowly!) I have John Hansen's book and I've been using it as a reference.
I'm an NXT-G guy. I LOVE graphical programming languages . So, I've started "copying" the NXT-G Robot Center programs to NXC. I'm on the ShooterBot with the Color Sensor program (but, I'm using a light sensor in my program).
1. I need help (in general) how to setup a sensor and using/reading from it.
2. How to use a While loop to control when I want the program to stop.
Here's the code (MUCH easier pasting NXC code than NXT-G code, lol! )
Code: Select all
task main() {
SetSensorType(S3, SENSOR_TYPE_LIGHT_INACTIVE);
SetSensorMode(S3, SENSOR_MODE_PERCENT);
while (ButtonState(BTNCENTER) = false) {
if (Sensor(S3) < 50) {
RotateMotor(OUT_B, 75, 954);
RotateMotor(OUT_C, 75, -954);
RotateMotor(OUT_BC, 75, 1440);
} else {
OnFwd(OUT_BC, 50);
}
}
}
Joey "jojoguy10"