View unanswered posts | View active topics It is currently Sun Jul 12, 2020 12:11 pm

Reply to topic  [ 2 posts ] 
>>NXT Servo Motor HELP PLEASE<< 
Author Message

Joined: Sat May 24, 2014 8:44 pm
Posts: 9
Post >>NXT Servo Motor HELP PLEASE<<
I am trying to program my robot to move forward until it detects an object. After it detects an object, the motors will stop and the arm being controlled with the servo motor will lower. Please look at my code and tell me what I am doing wrong:

#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Sensor, S2,     touch,          sensorTouch)
#pragma config(Sensor, S3,     light,          sensorLightActive)
#pragma config(Sensor, S4,     sonarSensor,    sensorSONAR)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorTetrix, openLoop, encoder)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorTetrix, openLoop, reversed, encoder)
#pragma config(Servo,  srvo_S1_C2_1,    servo1,               tServoStandard)
#pragma config(Servo,  srvo_S1_C2_2,    servo2,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_6,    servo6,               tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
  int Position;              // servo arm position

  servo[servo1] = 160;        // Initial servo position
  wait1Msec(10000);             // The program waits 50 milliseconds to initialize the light sensor.
   while(SensorValue(sonarSensor) > 25)

      motor[motorD] = 5;
      motor[motorE] = 5;


   motor[motorD] = 0;
   motor[motorE] = 0;

   wait1Msec(1000);                    // Pause for 1 second
      for (Position = 75; Position > 10; Position--)
        servo[servo1] = Position;              // lower dispenser arm
      wait1Msec(1000);                    // Pause for 1 second
      for (Position = 10; Position < 75; Position++)
        servo[servo1] = Position;              // raise dispenser arm

Thu May 07, 2015 1:24 pm

Joined: Thu Dec 01, 2011 12:07 am
Posts: 151
Post Re: >>NXT Servo Motor HELP PLEASE<<
Maybe you could tell us what it is actually doing?

Thu May 07, 2015 9:57 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests

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.