Hello,
My name is Matt and I’m a beginner program. I was wondering if anyone can tell me how to program the VEX line followers. I found some sample code, but it was for Easy C Pro, not the version of Cortex we have to use.
Thanks!
Matt
Here is the help page.
EasyCv4, Help, Search, “follower” in the search box, scroll down to Line Follower
Or just drag and drop “line follower” from the Inputs section into your program,
the help button has similar info.
More detailed questions will get your more detailed answers.
- What version of Cortex and EasyC do you have to use?
- What part of the sample code did you find inadequate?
Hi,
I have V4 and the sample code was:
https://vexforum.com/wiki/images/b/b4/Line_Follower_Figure_2.jpg
We were unable to find the correct solution through search, I tried that already before making an account. I’m new to Easy C, but I know C++, Java, .Net, and 3 others.
Thanks!
Hi Matt,
You get 1 point for mentioning using search before posting,
and 1 point for showing which sample code your found,
but zero additional points because you didn’t do any of the following:
- answer the second ? “What part of the sample code did you find inadequate?”
- describe what you searched for
- describe what search results you found
- describe why the search results you found are insufficient to your needs
- even describe your needs.
A line sensor returns a reflected brightness value to an analog port.
The sample shows how to get the value from the analog port.
The line sensors have no additional programability than getting the value.
If you want to program your classroom protobot to follow a line, you’ll need to write code that reads the line follower sensor value, and decide how to move the wheels.
I can’t read your mind, so you’ll have to use more words to describe what you want.
A search through the little known VexForum, Code Section revealed,
EasyC Pro ( v3.x)
Autonomous with 4 ultra and 3 line sensor
EasyC v2.x
Line Tracker Code
These are Both EasyC Projects, but can not be loaded into EasyC v4.x.
I am providing PDF’s of the EasyC Flow Chart and the ‘C’ Code, for both Projects…
The “Autonomous with 4 ultra and 3 line sensor” might not work correctly, but it might be worth studying…
MarkO,
Thanks for posting the flowchart images - that will be helpful to anybody that wants to dust off this old code and get it going on the Cortex. For folks that just want to see a listing of the C source code (no flowchart view) of the 2nd project, scroll down in this thread.
Cheers,
- Dean
I was mildly surprised to see that EasyC 4.x won’t Load the older Project Files… I would never expect them to Compile/Run, but if you have a Working Project, it would be nice to migrate it over…
I actually put everything in the Zip File… One Stop Download…
And I see there have been a few Downloads…
Hi,
The ENTIRE code does not open, because it is for EASY C PRO, not for EASY C CORTEX V4, which is the software that we were provided. I had searched Line follower, Line follower Cortex, line follower sample code for Cortex, line code cortex, and easy c line follower programming. No codes that were compatible with our version were found. I said that the entire code is invalid, due to the fact that it is incompatible with our version of Easy C. I appreciate the links and samples you have provided
Thank you!
Your Welcome…
Please pass on to others, the Importance of being Thorough and Clear in asking for Assistance and what Steps you have taken to resolve the Issue…
As more Items get added to the Vex Universe, the more Choices and Solutions become prevalent. There is a chance of someone, inadvertently giving you, misinformation, by assuming something about your Issue, when in fact you were implying something else about it will become much more common… So Thorough and Clear will become Very Important to getting relevant help…
Yes this is true, yet we still need assistance in solving our issue. We are continuing to research for a code that is in easyC V4 for Cortex yet have not found anything that could possibly benefit us. Transferring the code or opening the files DO NOT work.
An answer would be GREATLY APPRECIATED
Well, you have the .pdf files that MarkO graciously posted. You can study that code and re-create the portions that you need. This thread has a discussion of the algorithm my team used, so that can help explain some of the code.
I believe you can cut-and-paste the C code from the pdf directly into user code in EasyC V4. There would probably be some fixing up to do, but it should mostly work.
Until you locate a ready-to-run set of code, that is probably your best avenue.
- Dean
I have a EasyC v4.x framework of the EasyC v2.x Project, created from the .PDF Files I posted earlier… I just need to Check My Work, before I post it.
Hello,
Thank you so much for your help and please post the v4.x code as soon as possible. I am sorry for all of your troubles.
Matt
Not a Problem… I will attache What I have… I would need to setup a Square Bot, with the Cortex and the Line Sensors to “Check my Work”…
This is a Start, following the EasyC 2.x Line Tracker Code from Quazar…
Please, keep asking questions, if you need assistance…
LineTrackerv4.zip (3.42 KB)
Hi,
Is that autonomous or manual? It has joystick commands…
THX Matt
Thanks guys this really is helping me a lot :D. Now I am trying to convert it into a autonomous code with motor ports 2,3,4, and 5 with three light sensors on the front so I will contact you if I need any more help. Thanks!
-Matt
:o I’m sorry I am having issues with the code that I am trying to write for the autonomous program that I was talking about earlier. Do any of you know how to debug it? I am sorry I am just a beginner I am unfamiliar with this. I want it to follow a white line of tape on the blue vex competition mats. Please help me if possible. Thank you for your time.
-Matt :o
Line follower program.zip (2.49 KB)
Were all the project files included? I opened in EasyC 4.1.0.1 and the function Track_Line() does not exist. This is what I have from you.
#include "Main.h"
void Autonomous ( unsigned long ulTime )
{
SetMotor ( 2 , -127 ) ;
SetMotor ( 5 , 127 ) ;
SetMotor ( 3 , -127 ) ;
SetMotor ( 4 , 127 ) ;
if ( Buttons_1 )
{
Buttons_1 = GetAnalogInput ( 2 ) ;
BLACK = Track_Line ( ) ;
SetMotor ( 2 , 0 ) ; // Turn Lamp Off
SetMotor ( 5 , 0 ) ;
continue ;
}
else if ( Buttons_2 )
{
Buttons_2 = GetAnalogInput ( 4 ) ;
BLACK = Track_Line ( ) ;
SetMotor ( 3 , 0 ) ; // Turn Lamp On
SetMotor ( 4 , 0 ) ;
//SetDigitalOutput ( 11 , 1 ) ; // Turn LED On
continue ;
}
/* Keep Adding Code In Here...... */
}
Your code so far: with my comment //??
void Autonomous ( unsigned long ulTime ) {
//?? no while loop?
SetMotor ( 2 , -127 ) ; // ?? why turn on motors before do anything?
SetMotor ( 5 , 127 ) ; SetMotor ( 3 , -127 ) ; SetMotor ( 4 , 127 ) ;
if ( Buttons_1 ) { // ?? Buttons_1 comes from where?
Buttons_1 = GetAnalogInput ( 2 ) ; // ?? redefine Buttons_1
BLACK = Track_Line ( ) ; //?? undefined function
SetMotor ( 2 , 0 ) ; // Turn Lamp Off, ?? why does motor affect lamp?
SetMotor ( 5 , 0 ) ;
continue ;
} else if ( Buttons_2 ) { //?? Buttons_2 not defined
Buttons_2 = GetAnalogInput ( 4 ) ; //?? redefined Buttons_2
BLACK = Track_Line ( ) ;
SetMotor ( 3 , 0 ) ; // Turn Lamp On
SetMotor ( 4 , 0 ) ;
//SetDigitalOutput ( 11 , 1 ) ; // Turn LED On
continue ; }
/* Keep Adding Code In Here...... */
}
Debugging:
- There is no documentation in F5 Controller configuration panel, so I can’t tell what ports go to what.
- There are no comments to follow what your intent is with the code.
- There are no global variables defined in the F6 Global panel.
It helps to have a variable defined for every Get… line.
The variable type should be appropriate for the type of Get.
Your have a “LightSensor” block, instead of “LineFollower” block, but they act the same GetAnalogInput, and they both return type unsigned int.
If Buttons_1 is a variable, it needs to be defined in the Global panel.
If BLACK is a variable to store the results of Track_Line(), it needs to be defined in the Global Panel. - There is no function Track_Line() defined.
I’m trying to keep my responses in scale to the effort I see you have put in so far.
[INDENT]I am sorry but in case you haven’t noticed I am a beginner programmer in easyc and I am only familliar with console applications in c++. I am trying to get my code running to the best of my abilities, which obviously is not enough considering that I do not have enough experience with the software. Effort is not my issue here. I was assigned this project for my autonomous class and a member of my team outside of class recommended that I came to this fourm. Thank you for your time so far and I apologize that I put you in the position to “scale your effort so far” with mine and lower yourself in an attempt to help a beginner who is eager to learn. In conclusion, I am going to put in enough effort as necessary to accomplish my task yet I am not sure what to do. I do not need you to program for me but I would like to utilize the knowledge and experience on this fourm to help me. Thank you.
-Matt[/INDENT]