View unanswered posts | View active topics It is currently Mon Nov 30, 2015 10:07 pm

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

Joined: Sun Jul 20, 2014 10:21 am
Posts: 9
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()


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
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 716
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 updated help documentation and the ROBOTC Forums.

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