View unanswered posts | View active topics It is currently Tue Feb 09, 2016 1:46 am

 Page 1 of 1 [ 5 posts ]
 Print view Previous topic | Next topic
Author Message
Rookie

Joined: Thu Dec 26, 2013 8:17 pm
Posts: 9
I can not get the encoders to work. (see previous post)
going to try this.

need robot to move forward
motor[right] = 20;
motor[left] = 20;
wait1msec(5000);

while it is doing that task, I need it to move a servo from 1 to 225.

if (SensorValue)(IR) = 5)

else

I do not want the robot to stop until it has timed out, I want the ir sensor to trigger the servo to move during the 5 second run of the robot.

I need a while loop, but where do I put it?
How do I make the 5 sec run a condition?
I wish my encoders worked.

Sat Jan 11, 2014 8:38 am
Guru

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
 sprtmed wrote:I do not want the robot to stop until it has timed out, I want the ir sensor to trigger the servo to move during the 5 second run of the robot.I need a while loop, but where do I put it?How do I make the 5 sec run a condition?I wish my encoders worked.

Instead of calling wait1Msec(5000) that makes the robot to sleep for 5 seconds and doing nothing else, you need to have the robot just loop and watch the clock until it reaches 5 seconds. While it is watching the clock, it could also watch the IR at the same time. Something like this. BTW, when you compare for equity, you need to use a double equal "==". A single equal is an assignment operator, not a logical compare operator.
 Code:motor[right] = 20;motor[left] = 20;ClearTimer(T1);while (time1[T1] < 5000){    if (SensorValue[IR] == 5)    {        servo[basket] = 255;    }    else    {        servo[basket] = 1;    }    wait1Msec(20);}motor[right] = 0;motor[left] = 0;

How do the encoders not work? Are they not reading correctly? Or is your code not behaving correctly? If so, how did it behave and what was the code?

Sat Jan 11, 2014 3:51 pm
Rookie

Joined: Thu Dec 26, 2013 8:17 pm
Posts: 9
Thank you again for your quick response. We tried the encoders on my recent "bat out of hell" post. We have a match this weekend and this is my last resort. We will be at the mercy of a battery charge, but I think we can score some points with this method. Trust me in the fact that I redid everything with the encoders. May try again after this coming weekend.

Sun Jan 12, 2014 10:43 am
Rookie

Joined: Thu Dec 26, 2013 8:17 pm
Posts: 9
Thanks for the help with the code. Did not know what to call the internal timer. We can Score!!!!

Mon Jan 13, 2014 10:47 am
Rookie

Joined: Fri Oct 24, 2014 6:51 am
Posts: 1
There's actually a different command for that. For the instantaneous Tetrix battery level, you use externalBattery. For the average Tetrix battery level, you use externalBatteryAvg.

_________________
You can easily check out our high quality sas exam which prepares you well for the real EXIN You can also get success in real University of Toronto exam.

Fri Oct 24, 2014 6:58 am
Display posts from previous:  Sort by
 Page 1 of 1 [ 5 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    2014 Robotics Academy Summer of Learning    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