View unanswered posts | View active topics It is currently Sat Dec 15, 2018 5:23 pm

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Start, Reverse, Stop on one button?
Author Message
Rookie

Joined: Fri Jan 11, 2013 7:49 am
Posts: 3
Start, Reverse, Stop on one button?
I'm a PLTW teacher and recently went to one of the Vex competitions in my area and saw that one team had their controller set up so that if they pushed a button on the controller and let go, a motor would run infinitely. They could also stop the motor, set it at a different speed, and put into reverse by doing the same thing with other buttons. A small group of students that I am taking to compete next week wants to do the same thing, but I don't know what the code would be. Any help?

Fri Jan 11, 2013 10:45 am
Moderator

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Re: Start, Reverse, Stop on one button?
Here is some pseudocode to get you started. It can be optimized more, but this will give you a general idea:
 Code:task main(){  int motorPower;  while(true){    if(button 1 is pressed){      motorPower = 127; // run motor full forwards    }    else if(button 2 is pressed){      motorPower = 63; // run motor half forwards    }    else if(button 3 is pressed){      motorPower = -127; // run motor full backwards    }    else if(button 4 is pressed){      motorPower = -63; // run motor half backwards    }    else if(button 5 is pressed){      motorPower = 0; // stop motor    }    motor[port1] = motorPower  }}

_________________
sudo rm -rf /

Fri Jan 11, 2013 11:58 am
Rookie

Joined: Fri Jan 11, 2013 7:49 am
Posts: 3
Re: Start, Reverse, Stop on one button?
Thank you so much! I put that up on my projector and my students saw that and got straight at it. They loaded it onto the Cortex and it works the way that they wanted it to.

Fri Jan 11, 2013 7:26 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 3 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

 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