Light blinking.nxc

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

Krúžok Robotiky

/* light_blinking.nxc

Program nahodne blika ziarovkami na vsetkych troch portoch A,B,C

Autor: Ivan Ryger

*/

int delay; //premenna delay
int i; //premenna i


task main()
{
 while(1) //nekonecna slucka
 {
  Off(OUT_ABC); //vypni A, B a C
  i=random(12); //i= nahodne c. do 12
  
  if (i%2==0) //ak je i delitelne dvomi
     OnFwd(OUT_A,50); //zapni port A na silu 50
  if(i%3) //ak je i delitelne tromi
     OnFwd(OUT_B,50); //zapni port B na silu 50
  if(i%4)//ak je i delitelne stirmi
     OnFwd(OUT_C,50); //zapni port C na silu 50

  delay=random(250)+50; //delay = cislo do 250 + 50
      Wait(delay); //cakaj podla delay

 }
}