View unanswered posts | View active topics It is currently Sun Dec 21, 2014 10:37 am






Reply to topic  [ 4 posts ] 
Code to move forward and turn with the encoders 
Author Message
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 406
Post Code to move forward and turn with the encoders
Code:
#pragma config(Sensor, dgtl1,  rightEncoder,        sensorQuadEncoder)
#pragma config(Sensor, dgtl3,  leftEncoder,         sensorQuadEncoder)
#pragma config(Motor,  port2,           rightMotor,    tmotorNormal, openLoop, reversed)
#pragma config(Motor,  port3,           leftMotor,     tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
  wait1Msec(2000);  //Two second Delay

  SensorValue[rightEncoder] = 0;  //Clear the right encoder value
  SensorValue[leftEncoder] = 0;   //Clear the left encoder value

  //While the encoders have spun less than 3 rotations...
  while(SensorValue[rightEncoder] < 1080)
  {
    //Move Forward
    motor[rightMotor] = 63;
    motor[leftMotor] = 63;
  }


  //Stop for half a second
  motor[rightMotor] = 0;
  motor[leftMotor] = 0;
  wait1Msec(500);


  SensorValue[rightEncoder] = 0;  //Clear the right encoder value
  SensorValue[leftEncoder] = 0;   //Clear the left encoder value

  //While the right encoder has spun less than 1 rotation...
  while(SensorValue[leftEncoder] < 360)
  {
    //Turn Left
    motor[rightMotor] = -63;
    motor[leftMotor] = 63;
  }

}

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Thu Sep 23, 2010 4:05 pm
Profile
Rookie

Joined: Wed Oct 13, 2010 12:27 am
Posts: 4
Post Re: Code to move forward and turn with the encoders
could you please help me write this code...The purpose of the LDR’S are to track the sun light and turn the solar panels 1 degree every 15 mins. Then after it has completed a course of 8 hours it should come back to its original position it was the previous day. (at night time).



3. The solar panels are already tilted to 15 degrees and it only need the LDR’S to be programmed to move 1 degree every 15 mins for an course of 8 hours. That’s all when it comes to programming the tracker.


Wed Oct 13, 2010 12:31 am
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 406
Post Re: Code to move forward and turn with the encoders
If you post your code, I'd be happy to offer up some suggestions and advice. :D

How do you plan on powering the Cortex for 8 hours at a time? The batteries won't last that long.

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Wed Oct 13, 2010 9:12 am
Profile
Rookie

Joined: Wed Oct 13, 2010 12:27 am
Posts: 4
Post Re: Code to move forward and turn with the encoders
it is just a project for school and the lecturer just want to findout from the net all the info and write up the code. so I was just hoping someone would be able to help. since i have no idea even where to start.


Wed Oct 13, 2010 9:30 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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.