View unanswered posts | View active topics It is currently Tue Feb 19, 2019 5:35 am

 Page 1 of 1 [ 5 posts ]
 Print view Previous topic | Next topic
program to stay near wall & program to go back and forth
Author Message
Rookie

Joined: Mon Mar 26, 2012 12:55 pm
Posts: 2
program to stay near wall & program to go back and forth
i am trying to create a program for my robot to sear within 8-10 cm of a wall. i have 2 sensors, one facing forward and one to the right. the square the robot will be in has walls that come out so the forward is necessary. the program i have made simply makes the robot go in circles and when it is with 8-10 cm it just stops.
 Code:void stayNearWall(){  while(SensorValue[sonarSensor1 || sonarSensor2] => 8){  motor(motorB)=50;  motor(motorC)=0;  wait1Msec(100);    motor(motorB)=50;  motor(motorC)=50;    }  while(SensorValue[sonarSensor1 || sonarSensor2]=< 10){  motor(motorB)=50;  motor(motorC)=0;  wait1Msec(100);    motor(motorB)=50;  motor(motorC)=50;}}

i also am trying to make a program that makes the robot go back and forth across the arena while moving forward each time. unfortunately, it is also a failure... any help is appreciated!!
 Code:void BackandForth(){  while(sensorValue[sonarSensor1 || sonarSensor2] > 12){  motor(motorB)=50;  motor(motorC)=50;}  //Left Turn  motor(motorB)=16.665;  motor(motorC)=-16.665;  wait1Msec(1150);  motor(motorB)=50;  motor(motorC)=50;  wait1Msec(100);  //Left Turn  motor(motorB)=16.665;  motor(motorC)=-16.665;  wait1Msec(1150);  motor(motorB)=50;  motor(motorC)=50;  wait1Msec(500);  while(sensorValue[sonarSensor1 || sonarSensor2] > 5){  motor(motorB)=50;  motor(motorC)=50;}  //Right Turn  motor(motorB)=-16.665;  motor(motorC)=16.665;  wait1Msec(1150);  motor(motorB)=50;  motor(motorC)=50;  wait1Msec(100);  //Right turn  motor(motorB)=-16.665;  motor(motorC)=16.665;  wait1Msec(1150);  motor(motorB)=50;  motor(motorC)=50;  wait1Msec(500);  while(sensorValue[sonarSensor1 || sonarSensor2] > 5){  motor(motorB)=50;  motor(motorC)=50;}  //Left Turn  motor(motorB)=16.665;  motor(motorC)=-16.665;  wait1Msec(1150);  motor(motorB)=50;  motor(motorC)=50;  wait1Msec(100);  //Left Turn  motor(motorB)=16.665;  motor(motorC)=-16.665;  wait1Msec(1150);  motor(motorB)=50;  motor(motorC)=50;  wait1Msec(500);  while(sensorValue[sonarSensor1 || sonarSensor2] > 5){  motor(motorB)=50;  motor(motorC)=50;}  //Right Turn  motor(motorB)=-16.665;  motor(motorC)=16.665;  wait1Msec(1150);  motor(motorB)=50;  motor(motorC)=50;  wait1Msec(100);  //Right turn  motor(motorB)=-16.665;  motor(motorC)=16.665;  wait1Msec(1150);  motor(motorB)=50;  motor(motorC)=50;  wait1Msec(500);}

Mon Apr 02, 2012 5:35 pm
Rookie

Joined: Wed Jul 21, 2010 11:23 pm
Posts: 39
Re: program to stay near wall & program to go back and forth
I'm thinking you might want to replace
 Code:while(SensorValue[sonarSensor1 || sonarSensor2] => 8)

with
 Code:while((SensorValue[sonarSensor1]>=8) || (SensorValue[sonarSensor2]>=8 ))

Mon Apr 02, 2012 10:48 pm

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Re: program to stay near wall & program to go back and forth
Ron,

It's certainly the most creative use of SensorValue and logic operators I have ever seen

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

Tue Apr 03, 2012 1:20 am
Rookie

Joined: Mon Mar 26, 2012 12:55 pm
Posts: 2
Re: program to stay near wall & program to go back and forth
ron,

thanks.

xander,

i think thats a compliment? this has been a nightmare for me!

Tue Apr 03, 2012 8:08 am

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Re: program to stay near wall & program to go back and forth
Yeah, it was a bit of a joke. It is amusing to see people do things that seem perfectly logical (pardon the pun) but that really don't work. I can see the thought process behind it and am somewhat surprised that I have not fallen into the same trap

Making mistakes, some even slightly amusing (to others anyway), are a great way to learn new things. I still make plenty of boneheaded mistakes and I've been programming for almost 18 years

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

Tue Apr 03, 2012 2:53 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 5 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