View unanswered posts | View active topics It is currently Fri Sep 19, 2014 7:57 pm






Reply to topic  [ 2 posts ] 
errors in basic encoder program 
Author Message
Rookie

Joined: Sun Jul 20, 2014 10:21 am
Posts: 5
Post errors in basic encoder program
#pragma config(Sensor, dgtl1, attachedtoright, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, attachedtoleft, sensorQuadEncoder)
#pragma config(Motor, port2, rightMotor, tmotorVex269_MC29, openLoop, reversed)
#pragma config(Motor, port3, leftMotor, tmotorVex269_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()

{
wait1Msec(2000);

SensorValue[rightEncoder] = 0;
SensorValue[leftEncoder] = 0;

while(SensorValue[leftEncoder] < 1800)

motor[rightMotor] = 63;
motor[leftMotor] = 63;
}


This code comes back with error messages on the two lines containing "SensorValue... Error reads "Undefined variables..."
This was the same program in the sample programs (which did work). Now when I write the same code myself, I get error messages. Help, please. Bob Sedlak, Lakewood High School


Tue Aug 19, 2014 11:20 am
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 578
Post Re: errors in basic encoder program
In your #pragma statements (generated by the Motors and Sensors Setup window), you've assigned the name of " attachedtoright" and " attachedtoleft" to your encoders. Later in the program, you try to reference them by name using the SensorValue command, but you are using the sample program's names of "rightEncoder" and "leftEncoder". This is most likely what is causing the issue.

I suggest either changing the name in the code to reflect the names you've given the encoders, or the name of the encoders in the Motors and Sensors Setup to reflect your code. Either way, this should resolve the issues you are running into.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Tue Aug 19, 2014 11:26 am
Profile
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.