View unanswered posts | View active topics It is currently Wed Apr 16, 2014 11:57 pm






Reply to topic  [ 31 posts ]  Go to page 1, 2, 3  Next
wall detection (touch) % wall detection(ultra sonic) 
Author Message
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post wall detection (touch) % wall detection(ultra sonic)
i have problem in two programs
with wall detections(touch)
and wall detections(ultra sonic)

the while loop not take the function that go forward, someone knows why?

1st program
const tSensors touchSensor = (tSensors) S1;//sensor touch
task main()
{
while(SensorValue(touchSensor) == 0)
//go forware
{
motor[motorA]=10;
motor[motorC]=10;
wait1Msec(4550);
}
//go backward
motor[motorA]=-3;
motor[motorC]=-3;
wait1Msec(4550);

2nd program
const tSensors bumper = (tSensors) S1;//sensor touch
task main()
{
while(SensorValue(bumper) == 0)
//go forware
{
motor[motorA]=10;
motor[motorC]=10;
wait1Msec(4550);
}
//go backward
motor[motorA]=-3;
motor[motorC]=-3;
wait1Msec(4550);


Wed Apr 17, 2013 7:02 am
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: wall detection (touch) % wall detection(ultra sonic)
What version of RobotC are you using? And could you please use the [code][/code] tags for your code? It makes it easier to read and understand.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Wed Apr 17, 2013 10:28 am
Profile WWW
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post Re: wall detection (touch) % wall detection(ultra sonic)
i use the latest version 3.6


Wed Apr 17, 2013 3:27 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: wall detection (touch) % wall detection(ultra sonic)
Ok well, I just took your code and indented it all myself. Several things stand out.

1. You don't have a closing brace for your task main()
2. You're not defining the S1 sensor type.
3. And I have no idea what you're trying to accomplish with "const tSensors touchSensor = (tSensors) S1;//sensor touch".

Try this code, it should work fine.

Code:
#pragma config(Sensor, S1,     touchSensor,    sensorTouch)

task main()
{
   //Go forwards if the touch sensor is NOT pressed.
   while(SensorValue(touchSensor) == 0)
   {
      motor[motorA]=10;
      motor[motorC]=10;
      wait1Msec(4550);
   }
   //else if is pressed go backwards.
   motor[motorA]=-3;
   motor[motorC]=-3;
   wait1Msec(4550);
}


and,

Code:
#pragma config(Sensor, S1,     bumper,    sensorTouch)

task main()
{
   //Go forwards if the touch sensor is NOT pressed.
   while(SensorValue(bumper) == 0)
   {
      motor[motorA]=10;
      motor[motorC]=10;
      wait1Msec(4550);
   }
   //else if is pressed go backwards.
   motor[motorA]=-3;
   motor[motorC]=-3;
   wait1Msec(4550);
}


FYI, these two programs are identical, they just have different names for the sensor. Also just wondering, why are your motor speeds so slow?

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Wed Apr 17, 2013 3:52 pm
Profile WWW
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post Re: wall detection (touch) % wall detection(ultra sonic)
thanks a lot bro, i try again with these codes,
i test the robot's sensor because i have a project in robotC but my area it is small for this reason i put lower speed, to control easy the robot


Thu Apr 18, 2013 7:08 am
Profile
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post Re: wall detection (touch) % wall detection(ultra sonic)
i try with this code but the while loop not working, when the Lego touch in the wall not go back, how to check if the Lego's sensor working?


Thu Apr 18, 2013 8:02 am
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: wall detection (touch) % wall detection(ultra sonic)
Ok, so you want it to go forwards until it hits the wall? If so, then try this:

Code:
#pragma config(Sensor, S1,     touchSensor,    sensorTouch)

task main()
{
   //Go forwards if the touch sensor is NOT pressed.
   while(SensorValue(touchSensor) == 0)
   {
      motor[motorA]=10;
      motor[motorC]=10;
      //wait1Msec(4550);
   }
   //else if is pressed go backwards.
   motor[motorA]=-3;
   motor[motorC]=-3;
   wait1Msec(4550);
}


I have commented out the wait time in the while loop, because if you do have it waiting it will only check the touch sensor every 4.55 seconds. That's bad. You also might get better results with some faster motor speeds. Even 25% would be good.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Thu Apr 18, 2013 10:23 am
Profile WWW
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post Re: wall detection (touch) % wall detection(ultra sonic)
thanks again bro, i try again with this code


Fri Apr 19, 2013 7:09 am
Profile
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post Re: wall detection (touch) % wall detection(ultra sonic)
again not working bro,
how to check if the robot's sensor it working great?


Sat Apr 20, 2013 4:18 am
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: wall detection (touch) % wall detection(ultra sonic)
Go to the "view" menu, and select touch sensor. That'll tell you if it's working or not.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Sat Apr 20, 2013 11:07 am
Profile WWW
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post Re: wall detection (touch) % wall detection(ultra sonic)
thanks a lot bro


Sun Apr 21, 2013 3:21 am
Profile
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post Re: wall detection (touch) % wall detection(ultra sonic)
i not found the touch sensor in "view" menu
i uploaded the print screen


Attachments:
view menu.png
view menu.png [ 121.88 KiB | Viewed 2210 times ]
Sun Apr 21, 2013 3:59 am
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: wall detection (touch) % wall detection(ultra sonic)
No, no, on the NXT. You scroll through it's menu screen until you see "View".

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Sun Apr 21, 2013 9:27 am
Profile WWW
Expert

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 186
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post Re: wall detection (touch) % wall detection(ultra sonic)
NeXT-Generation wrote:
No, no, on the NXT. You scroll through it's menu screen until you see "View".



That's where my friends apostrophe went!

Sorry, I couldn't resist. If you look one my profile on of my interests is correct grammar.

_________________
I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot
Play chess for free!


Last edited by Coder A on Tue Apr 23, 2013 2:12 pm, edited 1 time in total.



Sun Apr 21, 2013 7:37 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: wall detection (touch) % wall detection(ultra sonic)
No, no, I, am like, way, way, correct. :lol: We unfortunate Americans say "No, no" when we correct someone. :lol:

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Sun Apr 21, 2013 7:43 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 31 posts ]  Go to page 1, 2, 3  Next

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.