I was wondering if there is any way to program the controler to compair two light inputs and move towards the highest one.
A sample program would be nice too
I was wondering if there is any way to program the controler to compair two light inputs and move towards the highest one.
A sample program would be nice too
Reported.
To answer your question you would want to make two measurements. The first one of the first light source and then another of the second light source. Then you could use an if statement to determine where to go. For example:
if(a>b)
goto light a
if(b>a)
goto light b
i might just be an epic failz after all becuse that is still confusing (im sort of new to programming Vex) i understand how to make it turn when it hits a certain point but other then that im kind of lost.
Here is a short program that should help you along.
Youāre never an āepic failzā whoever wrote that is whats called a troll. They are people who post things to ā ā ā ā others off. Ignore it, the moderators will delete.
LightSensor Choice.zip (1.15 KB)
With a User Name of āU faleā, what would you expect?? Life is tough enough, with out the Trolls out there that are bored.
Thereās another example under the Light Seeker project at this link. Itās not exactly the same as your project, but you can use 2 separate light sensors and eliminate the servo (no need to turn the sensor to 2 positions, since you have 2 sensors.
Itās hard to believe that there are people who would send a reply like that on this forum - Iām glad that you were able to get some help with your project.
Never hesitate to ask for help - weāve all needed it from time to time. Things can be confusing sometimes, especially when you are just starting out.
So have you got it to work?
A Vexmentor sent me a program and it was helpful in getting it in my head but it dident work so im kind of still working on a program.
And also the guy named Ufail is sort of my classmate who is working on the same project. However trolling is a big thing that is wrong with the internet.
Hey this is tkwireās other classmate, weāre working on the same project with the light sensor. We are however stuck on the part where we have to make it read and then compare then move towards the brightest light, however what we have managed to do, is have it spin around until it gets a certain light amount. Any help will be appreciated.
Can you guys post your code? That way we can see what you already have an help you move on from there.
i will try im not really sure how so i will post it as a download.
lol so that dident work. [ATTACH]786[/ATTACH]
Looks like it should work, except that everything needs to be in an endless loop.
#include "Main.h"
void main ( void )
{
unsigned int leftlight = 0;
unsigned int rightlight = 0;
while ( 1 ) // Loop Forever!!!
{
rightlight = GetAnalogInput ( 3 ) ;
leftlight = GetAnalogInput ( 4 ) ;
if ( rightlight > leftlight )
{
SetMotor ( 2 , 0 ) ;
SetMotor ( 3 , 0 ) ;
Wait ( 200 ) ;
}
if ( leftlight > rightlight )
{
SetMotor ( 2 , 255 ) ;
SetMotor ( 3 , 255 ) ;
Wait ( 2000 ) ;
}
else
{
SetMotor ( 2 , 0 ) ;
SetMotor ( 3 , 255 ) ;
}
}
}
See Attached Project.
easyC_light_help-001.zip (1.57 KB)
wow thanks it worked, just added the limit switch bumpers and the ultrasonic and now itās set to go, thanks for the help that helped me understand it better.
wow thanks it worked, just added the limit switch bumpers and the ultrasonic and now itās set to go, thanks for the help that helped me understand it better.
No Problemā¦
Just remember that when it comes to Programming/Code issues, it really helps to āPost Your Codeā.
If you have any other questions, just askā¦
Both me and my clasmate would like to thank all of you who helped with our programing and fine tuning.
Hi,
Heres my take:
void main ( void )
{
unsigned int leftlight = 0;
unsigned int rightlight = 0;
int diff;
while ( 1 ) // Loop Forever!!!
{
rightlight = GetAnalogInput ( 3 ) ;
leftlight = GetAnalogInput ( 4 ) ;
// change 10 bit to 8 bit value (also helps reduce noise)
rightlight = rightlight >> 2;
leftlight = leftlight >> 2;
// now you should get +- 255
diff = left - right;
// shift the 'center' to 127
diff += 127;
// limit the scale to 0 to 255
if(diff < 0) diff = 0;
else if(diff > 255) diff = 255;
// you may need to invert your motors / direction depends on the behaviour
// motors should turn your squarebot towards the light source.
SetMotor ( 2 , diff ) ;
SetMotor ( 3 , diff ) ;
Wait ( 50 ) ;
}
}
Hope this helps, or just take it as something to think about. Not tested but the idea should be there