View unanswered posts | View active topics It is currently Wed Jun 26, 2019 1:41 am






Reply to topic  [ 3 posts ] 
Touch Sensor - Bump Count 
Author Message
Rookie

Joined: Tue Jan 13, 2015 11:30 pm
Posts: 10
Post Touch Sensor - Bump Count
Hi,

I am new to RobotC and am working on learning some of the different features. My brick is an EV3 and I have RobotC 4.27.

So, I am trying to write a background task which stops the program when the touch sensor has been bumped 3 times. I thought it would be simple enough to use the getBumpedValue() function in a while loop. It seems that the getBumpedValue() function doesn't always reset as I would expect. Then the second time I run the program, the while loop gets skipped (touch sensor never presses) and the program instantly ends.

So, Any idea why the following 4 examples work or don't work?

1) This only works once. The second time the program is run, the while loop is skipped over:

resetBumpedValue(Touch);
while(getBumpedValue(Touch) < 3)
{
}

stopAllTasks();

2) This works perfectly. I can run the program multiple times.

while(getBumpedValue(Touch) < 3)
{
}
resetBumpedValue(Touch);
stopAllTasks();


3) This works perfectly. I can run the program multiple times.

string sValue;

sValue = getBumpedValue(Touch);
displayBigTextLine(1, sValue);
sleep(1000);

resetBumpedValue(Touch);

sValue = getBumpedValue(Touch);
displayBigTextLine(1, sValue);
sleep(1000);

while(getBumpedValue(Touch) < 3)
{
}
stopAllTasks();

4) This only works once. The second time the program is run, the while loop is skipped over(this is the same as #3 except no time delays):

string sValue;

sValue = getBumpedValue(Touch);
displayBigTextLine(1, sValue);

resetBumpedValue(Touch);

sValue = getBumpedValue(Touch);
displayBigTextLine(1, sValue);

while(getBumpedValue(Touch) < 3)
{
}
stopAllTasks();


Wed Jan 14, 2015 12:14 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Touch Sensor - Bump Count
The bump count reset issue was fixed in the latest version of ROBOTC: http://www.robotc.net/blog/2014/12/23/r ... 4-28-beta/

= 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]


Wed Jan 14, 2015 3:05 am
Profile WWW
Rookie

Joined: Tue Jan 13, 2015 11:30 pm
Posts: 10
Post Re: Touch Sensor - Bump Count
Thanks. I will download the 4.28 beta this evening.


Wed Jan 14, 2015 2:46 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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:  
cron



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.