Dopredu dozadu2.nxc

From RoboWiki
Revision as of 10:21, 26 March 2008 by Palo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Krúžok Robotiky

/* dopredu_dozadu.nxc

Robot sa nahodne pohybuje

Autor: Matej Kurilla

*/

int zakruta= 500;
int silnejsi= 50;
int slabsi= 20;

int cas;
int motory;
int vypnutie;

task main()
{
 while(1)
 {
  Off(OUT_AC);
  cas=random(3000)+500;
  motory=random(6);

  if ((motory%2)==0)
     {
     OnFwd(OUT_AC,silnejsi);   //dopredu
     Wait(cas);
     }
  if((motory%3)==0)
     {
     OnRev(OUT_AC,silnejsi);  //cúvanie
     Wait(cas);
     }
  if((motory%4)==0)
     {
     OnFwd(OUT_C,silnejsi);  //otáčanie  do prava
     OnFwd(OUT_A, slabsi);
     Wait(zakruta);
     }
  if((motory%5)==0)
     {
     OnFwd(OUT_A,silnejsi);  //otáčanie  do ľava
     OnFwd(OUT_C, slabsi);
     Wait(zakruta);
     }
  if((motory%6)==0)
     {
     Off(OUT_AC);    //vypnutie motorov
     Wait(cas);
     }


 }
 
}