Prekazka dotyk.nxc

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

Krúžok Robotiky

task AvoidWall()
{
/*


  menu->view->druh_senzora(ultrasonic, napr, )->select

  maximalne zobrazuje do 150cm
*/
  SetSensorTouch(IN_1);

  while(true)
  {         //nastavime senzor ako dotykovy

           if (SENSOR_1==1) //ak je prekazka blizko
           {
            OnRev(OUT_AC,50);//dozadu na 50perc. 2 motor, aby sa vratil
            //idu naopak
            Wait(1000);//cakaj 3 sec;

            OnFwd(OUT_A,50);//dopredu na 50perc. 1 motor, aby sa stocil
            Wait(750);
            OnFwd(OUT_C,50);//dopredu na 50perc. 2. motor,
            //aby sa rozbehol rovno

           }

  }
}

task main()
{
     start AvoidWall; //spust thread AvoidWall
     
     //nedaju sa pouzivat funkcne prototypy
     OnFwd(OUT_AC,50);//dopredu na 50perc. oba motory
     Wait(3000*60);//cakaj 3 sec
     Off(OUT_AC);//vypni motor brzdnym prudom
     Wait(100);//pockaj chvilu
     Float(OUT_AC);//zastav motor odstavenim napajania
     
     
}

/*

  na konci tools->find brick
  compile
  compile->download
*/