need university help first year

Please support our Legacy and Other Languages advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2009
Posts: 7
Reputation: umarmaqsood is an unknown quantity at this point 
Solved Threads: 0
umarmaqsood umarmaqsood is offline Offline
Newbie Poster

need university help first year

 
-1
  #1
Sep 25th, 2009
hey this is umar here and i really needed some help because i have my exam tommorow. i was assigned to make a robot. ad to program it as some of may you know( i hope) the NXC language (i think its called that) to program the Mindstorms nxt brick. if some can help me i only have limited knowledge, i need to make this robot stay away from this color yellow and stay in black , i will be given a a small rink or arean painted black (as big as a air hockey table) and rest painted yellow. there will also be another robot that will try to catch my robot so i have to make my robot escape for about 90 secs. i have written some code if some of you can help that would be great.[description of my robot: its both sensors are on the front( light sensor facing ab to the ground and the distance one facing straight forwarf) the two motors are on the front wheels and one tire on the back. and here is my code so far.


#include "NXCDefs.h"

mutex moveMutex;
#define dist  60
#define extranear  10
int tries = 0;




inline void scan_front()
{
  
  SetSensorLowspeed(IN_1);
  



if (SensorUS(IN_1) > dist)
{

    OnFwd(OUT_AB, 75);
	tries = 0;
}	

if (SensorUS(IN_1) < dist){

Off(OUT_AB);
RotateMotor(OUT_A, 80, 300);
tries++;


}

if(SensorUS(IN_1) < extranear)

{
Off(OUT_AB);

RotateMotor(OUT_A, 80, 720);


}


if(tries >= 3 ){
Off(OUT_AB);
 OnFwd(OUT_AB, 75);
}




}






task main()
{
 

while (true){


scan_front();




}



}

*Update: the tries thing i did doesnt seem to work.
Last edited by umarmaqsood; Sep 25th, 2009 at 2:33 am.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,867
Reputation: ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all 
Solved Threads: 120
ithelp's Avatar
ithelp ithelp is offline Offline
Posting Virtuoso

Re: need university help first year

 
0
  #2
Sep 25th, 2009
You have got a good assignment .Do not mix 2 operation , first code "stay away" from other robot and then try to avoid color , there may be situtation like robot cannot avoid color to stay away from the other robot.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 7
Reputation: umarmaqsood is an unknown quantity at this point 
Solved Threads: 0
umarmaqsood umarmaqsood is offline Offline
Newbie Poster

Re: need university help first year

 
0
  #3
Sep 25th, 2009
can you guys help me with the coding a bit, im not asking the whole thing but can you make me the escape snipet and give me advice for the rest, if possible that would be great. thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Legacy and Other Languages Forum


Views: 965 | Replies: 2
Thread Tools Search this Thread



Tag cloud for Legacy and Other Languages
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC