View unanswered posts | View active topics It is currently Wed Aug 21, 2019 10:25 am

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Help with firefly bot 1
Author Message
Rookie

Joined: Mon Nov 09, 2015 12:56 pm
Posts: 2
Help with firefly bot 1
Does anyone know how can I compare the values of the light sensor? I need to take the highest value and make the robot go to that point

Mon Nov 09, 2015 2:28 pm
Moderator

Joined: Tue May 19, 2015 3:07 pm
Posts: 91
Re: Help with firefly bot 1
So if you wanted to make a robot spin in place to find the angle of the largest light value you would do something like this

 Code:#pragma config(StandardModel, "SQUAREBOT - IME")//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//task main(){   //the value of currentEncoderTicks after having     //completed an entire rotation    int totalEncoderTicksInFullRotation=100;    int largestLightSeen=0;    int encoderTickOfLargestValue=0;    int currentEncoderTicks=0;    motor[leftMotor]=-20;    motor[rightMotor]=20;    while(currentEncoderTicks<=totalEncoderTicksInFullRotation){        currentEncoderTicks = nMotorEncoder[rightMotor]-nMotorEncoder[leftMotor];        if(SensorValue[light]>largestLightSeen){            largestLightSeen=SensorValue[light];            encoderTickOfLargestValue=currentEncoderTicks;        }       wait1Msec(50);//not hog the cpu    }    stopAllMotors();    }

Right now it will not turn a full rotation because I used a "magic" number of 100 encoder ticks per full rotation. Try out a few numbers until you find out how many ticks it takes your robot to spin a full rotation. So this program will find the angle of the largest light value. Turning to that angle should be fairly straight forward.

Tue Nov 10, 2015 11:23 am
Rookie

Joined: Mon Nov 09, 2015 12:56 pm
Posts: 2
Re: Help with firefly bot 1
Thanks man it really works, but the problem is that when I make the robot spin to the largest value after it has completed a full rotation, he doesn't go to the exactly to the light position so i cant't go straight forward. Do you know how to fix it?

Fri Nov 13, 2015 9:50 am
Moderator

Joined: Tue May 19, 2015 3:07 pm
Posts: 91
Re: Help with firefly bot 1
If you are having issues turning to light after finding its location I would recommend turning to the angle you believe it to be at and when you get close to the angle switch to turning to look for the value that you represents the fire. Use the encoder data to get you within something like 5 degrees of the correct angle and then use the line sensor to look for the variable
largestLightSeen

If you can't get something like that to work if you post your code I can give some pointers to get you facing the right direction. (I made a pun)

Fri Nov 20, 2015 3:38 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 4 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning