Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
2 kaklik 1
void cikcak()
2
{
3
short int movement;
4
 
5
   if(uhel>STRED)
6
   {
7
      movement = R;
8
      uhel=KOLMO1;
9
      Delay_ms(60);
10
   }
11
 
12
   if(uhel<STRED)
13
   {
14
      movement = L;
15
      uhel=KOLMO2;
16
      Delay_ms(60);
17
   }
18
 
19
sem:
20
   sensors = spi_read(0);         // cteni senzoru
21
   sensors=~sensors;
22
   Delay_ms(5);                  // cekani na SLAVE nez pripravi data od cidel
23
   if(!bit_test(sensors,3) == sensors)
24
   {
25
      if(R == movement)
26
      {
27
         FR;BL;
28
         movement=L;
29
         While(bit_test(sensors,3) == sensors)
30
         {
31
            sensors = spi_read(0);         // cteni senzoru
32
            sensors=~sensors;
33
            Delay_ms(5);
34
         }
35
         STOPL;STOPR;
36
         GoTo sem;
37
      }
38
 
39
      if(L == movement)
40
      {
41
         FL;BR;
42
         movement=R;
43
         While(bit_test(sensors,3) == sensors)
44
         {
45
            sensors = spi_read(0);
46
            sensors =~ sensors;
47
            Delay_ms(5);                  // cekani na SLAVE nez pripravi data od cidel
48
         }
49
 
50
         STOPL;STOPR;
51
         GoTo sem;
52
      }
53
   }
54
}
55
////////////////////////////////////////////////////////////////////////////////
56
void objizdka()
57
{
58
         // zjisti, jestli neni cihla, pouze pokud se jede jakztakz rovne
59
 
60
   BL; BR;
61
   While(bit_test(sensors,3) == sensors)
62
   {
63
      sensors = spi_read(0);
64
      sensors =~ sensors;
65
      Delay_ms(5);
66
   }
67
 
68
   STOPR; STOPL;
69
   delay_ms(1000);
70
   cikcak();
71
   delay_ms(1000);
72
 
73
   STOPR; STOPL;
74
   While(true);
75
 
76
   uhel=STRED-55;
77
   FR;STOPL;
78
   Delay_ms(370);       // doleva
79
 
80
   uhel=STRED;
81
   FL;FR;
82
   Delay_ms(200);       // rovne
83
 
84
   uhel=STRED+55;
85
   STOPR;FL;
86
   Delay_ms(300);       // doprava
87
 
88
   STOPR; STOPL;
89
   While(true);
90
 
91
   uhel=STRED;
92
   FR;FL;
93
   Delay_ms(250);       // rovne
94
 
95
   uhel=STRED+80;
96
   FL;STOPR;
97
   Delay_ms(300);       // doprava
98
 
99
   uhel=STRED;
100
   FR;FL;
101
   Delay_ms(100);       // rovne
102
 
103
   STOPR; STOPL;
104
 
105
   While(true);
106
 
107
/*   uhel=STRED;
108
   sensors=0b00001000;
109
   Delay_ms(1000);
110
   FL;FR;*/
111
 
112
}