View unanswered posts | View active topics It is currently Tue Oct 21, 2014 8:14 pm






Reply to topic  [ 1 post ] 
Segway using only NXT motors and one touch sensor 
Author Message
Expert

Joined: Wed Jun 30, 2010 7:15 am
Posts: 181
Post Segway using only NXT motors and one touch sensor
Yesterday, I tried making a segway using an ultrasonic sensor (which didn’t work), so I tried again today. Instead of a regular sensor, is used the rotation sensor in a third motor, and a touch sensor to activate it, which actually worked pretty ok. I've got more info, pictures and a video at this post on my blog. Even though the program needs some fine tuning and editing, here it is:
Code:
#pragma config(Sensor, S3,     TouchSensor,         sensorTouch)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main(){

   int currentValue;
   int doubleValue;
   int degreeToStraighten;
   int finalSpeed;

   while (SensorValue (TouchSensor) == 0) {}
   
   nMotorEncoder[motorB] = 0;
   PlaySound(soundBeepBeep);

   while (true){
     if (nMotorEncoder[motorB] < 0){
    currentValue = nMotorEncoder[motorB];
    doubleValue = currentValue + currentValue; // turn current value into
    degreeToStraighten = currentValue - doubleValue; // negative number
    finalSpeed = degreeToStraighten * degreeToStraighten * 3;   
   
      motor[motorA] = finalSpeed;
      motor[motorC] = finalSpeed;   
    }
   
    else{
    currentValue = nMotorEncoder[motorB];
    doubleValue = currentValue + currentValue; // turn current value into
    degreeToStraighten = currentValue - doubleValue; // negative number
    finalSpeed = degreeToStraighten * degreeToStraighten * 3;   
       
      motor[motorA] = -finalSpeed;
      motor[motorC] = -finalSpeed;
    }
   }
}


Wanna know more about this segway? check the following post(s):
Segway using motors post
video on YouTube

_________________
leonoverweel.com


Mon Oct 18, 2010 5:04 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

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.