View unanswered posts | View active topics It is currently Tue May 21, 2019 11:43 am






Reply to topic  [ 7 posts ] 
Firefly Bot 1 RVW programming help? 
Author Message
Rookie

Joined: Sat Jul 12, 2014 6:20 am
Posts: 5
Post Firefly Bot 1 RVW programming help?
Hi, I'm new. my code isn't working properly the bot just runs around the light but doesn't stop, and it's supposed to stop when it gets close to the light (I'm not sure how close so I just picked 100 for the light value). Maybe if you look at my code you can see where I'm going wrong. I was thinking that if the loop was "do until SensorValue(S3)=100" then it might work but I don't think there is a "do until" so that's why I used "while". Or maybe I'm completely off track. Any advice greatly appreciated. I'm stumped. :D :?:
Code:
task main()
{
while(SensorValue(S3)<100)
{
   forward(50);
   untilTouch(S1);
   pointTurn(left,50);
   untilRelease(S1);
   wait(.5);
   
}
stop();
}


Sat Jul 12, 2014 6:51 am
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Firefly Bot 1 RVW programming help?
Well, the maximum value that you can get from a light sensor is 100. So, your code keeps repeating until the light sensor reports its max value, which very rarely happens. I would recommend experimenting with lower and lower values until you find one that works.

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Sat Jul 12, 2014 10:15 am
Profile
Rookie

Joined: Sat Jul 12, 2014 6:20 am
Posts: 5
Post Re: Firefly Bot 1 RVW programming help?
thanks. I changed it but I think my code is probably all wrong. I took out the line untilRelease because i didn't really need it and I changed the light value but it only stops when it touches the light. Back to the drawing board.


Sat Jul 12, 2014 7:25 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Jun 11, 2014 9:59 am
Posts: 115
Post Re: Firefly Bot 1 RVW programming help?
Noobot, please let me know if I am understanding your problem correctly. Your robot will not stop until it touches the light, even if the sensor value is greater than your threshold before touching it reaches the light. If this is the case, there is nothing wrong with your code. When you use a while loop, the condition is only checked after it completes all other tasks inside the while loop.

With the code you are using, it is waiting until touch, turns, waits until release, and then waits for .5. It will only recheck the condition after these tasks are completed.

Please let me know if I am understanding the problem correctly, or if you have any other questions.


Mon Jul 14, 2014 10:41 am
Profile
Rookie

Joined: Sat Jul 12, 2014 6:20 am
Posts: 5
Post Re: Firefly Bot 1 RVW programming help?
yep you understand :)
ok sorry I've edited this post a few times now. I think I have it now. it seems to work but it's not saying challenge complete yet.

Code:
task main()
{

while(SensorValue(S3) < 60)
   {
   while(SensorValue(S1)!=1)
   {forward(50);
   wait1Msec(1);
   if (SensorValue(S3)>=60){break;}
   stop();

   }
   if (SensorValue(S3)>=60){break;}
   pointTurn(left,40);
   wait(1);
}
stop();


Mon Jul 14, 2014 5:37 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Jun 11, 2014 9:59 am
Posts: 115
Post Re: Firefly Bot 1 RVW programming help?
There are no achievements for this activity, so you will not see a completed challenge banner, even though you have completed the task.


Fri Jul 18, 2014 1:33 pm
Profile
Rookie

Joined: Sat Jul 12, 2014 6:20 am
Posts: 5
Post Re: Firefly Bot 1 RVW programming help?
lol, thanks Icarozza for all your help :bigthumb: . I just wanted to mention that the activity before Firefly Bot 1 is Line Runner 1 it has no achievements but does say completed when you finish. So hopefully my question looks slightly less dumb now :D or maybe not :wink:


Sat Jul 19, 2014 7:14 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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.