View unanswered posts | View active topics It is currently Thu Jul 31, 2014 5:38 pm






Reply to topic  [ 2 posts ] 
Please help with bumpswitch! 
Author Message
Rookie

Joined: Sat May 25, 2013 3:01 pm
Posts: 3
Post Please help with bumpswitch!
This is What I have
Code:
 #pragma config(Sensor, in3,    pot,            sensorPotentiometer)
#pragma config(Sensor, dgtl4,  bumpSwitch,     sensorTouch)
#pragma config(Sensor, dgtl6,  bump2,          sensorTouch)
#pragma config(Motor,  port2,           theMotor,      tmotorVex393, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
task main()
{
 while(true){
 
 
untilBump(dgtl4);
{
 if(SensorValue(pot) < 50)
 {
 motor[theMotor]=30;
 }
 if(SensorValue[pot] > 3000)
 {motor[theMotor]=-30;}
}
untilBump(dgtl6);
{
 motor[theMotor] = 0;}
}
}

I want the program to turn on if and only if "bumpSwitch" has been pressed and released not simply pressed and held, and turn of when "bump2" is pressed and released. This program only works when I hold down bumpSwitch and continue to hold it. Other wise the motor just runs continuously and I don't have enough experience to figure out what the problem is. Please help


Wed May 29, 2013 7:32 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3165
Location: Rotterdam, The Netherlands
Post Re: Please help with bumpswitch!
Please do not send PMs to ask for help. If I send it to you via PM, then nobody else will benefit from it later. When you post a question, allow 24 hours for people to respond. Just keep that in mind for next time.

Anyway, I played around a bit with your program and this is what I came up with. It doesn't do the bumped thing for the second switch because that would make your program quite a bit more complicated but it simply waits for you to press that button and will continue to run the program while you keep your fingers away from it.

Code:
#pragma config(Sensor, in3,    pot,            sensorPotentiometer)
#pragma config(Sensor, dgtl4,  bumpSwitch1,    sensorTouch)
#pragma config(Sensor, dgtl6,  bumpSwitch2,    sensorTouch)
#pragma config(Motor,  port2,           theMotor,      tmotorVex393, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
  // Wait for the bumpSwitch to be bumped
  untilBump(bumpSwitch1);
 
  // This runs until the bumpSwitch2 switch changes to true
  // That only happens when it is pressed.
  while (SensorBoolean[bumpSwitch2] == false)
  {
     if(SensorValue(pot) < 50)
     {
       motor[theMotor]=30;
     }
    
     if(SensorValue[pot] > 3000)
     {
       motor[theMotor]=-30;
     }
   }
  motor[theMotor] = 0;
}


Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Thu May 30, 2013 5:59 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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.