Subversion Repositories svnkaklik

Rev

Rev 251 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 251 Rev 361
Line 1... Line 1...
1
// Program pro MiniSumo na R-Day 2006
1
// Program pro MiniSumo na R-Day 2006
2
//"$Id: cholerik.c 251 2007-04-23 21:31:59Z kaklik $"
2
//"$Id: cholerik.c 361 2007-09-09 15:09:55Z kakl $"
3
 
3
 
4
#include "cholerik.h"
4
#include "cholerik.h"
5
 
5
 
6
#define THRESHOLD     15     // rozhodovaci uroven pro okraj areny
6
#define THRESHOLD     15     // rozhodovaci uroven pro okraj areny
7
                            // 0-15 (od 0.25 do 0.75 Vdd)
7
                             // 0-15 (od 0.25 do 0.75 Vdd)
8
                            // 0 jasnejsi; 15 tmavsi
8
                             // 0V cerna; 5V bila
-
 
9
 
-
 
10
#define KOLIKRAT     3//10
9
 
11
 
10
//motory            //Napred vypnout potom zapnout!
12
//motory            //Napred vypnout potom zapnout!
11
#define FR         output_low(PIN_B5); output_high(PIN_B4)  // Vpred
13
#define FR         output_low(PIN_B5); output_high(PIN_B4)  // Vpred
12
#define FL         output_low(PIN_B7); output_high(PIN_B6)
14
#define FL         output_low(PIN_B7); output_high(PIN_B6)
13
#define BR         output_low(PIN_B4); output_high(PIN_B5)  // Vzad
15
#define BR         output_low(PIN_B4); output_high(PIN_B5)  // Vzad
Line 210... Line 212...
210
         BL; FR;
212
         BL; FR;
211
         delay_ms(100);
213
         delay_ms(100);
212
         STOPL; STOPR;
214
         STOPL; STOPR;
213
      }
215
      }
214
 
216
 
215
      if (sr>10)     // Nepritel vpravo
217
      if (sr>KOLIKRAT)     // Nepritel vpravo
216
      {
218
      {
217
         FL; FR;                 // popojed rovne
219
         FL; FR;                 // popojed rovne
218
         for(n=0; n<5000; n++)
220
         for(n=0; n<5000; n++)
219
         {
221
         {
220
            if (arena_l || arena_r) {BL; BR; delay_ms(100); goto LOOP;};
222
            if (arena_l || arena_r) {BL; BR; delay_ms(100); goto LOOP;};
Line 230... Line 232...
230
            if (sl>5) {BL; FR;};
232
            if (sl>5) {BL; FR;};
231
            if (sr>5) {FL; BR;};
233
            if (sr>5) {FL; BR;};
232
         };
234
         };
233
      }
235
      }
234
 
236
 
235
      if (sl>10)     // Nepritel vlevo
237
      if (sl>KOLIKRAT)     // Nepritel vlevo
236
      {
238
      {
237
         FL; FR;                 // popojed rovne
239
         FL; FR;                 // popojed rovne
238
         for(n=0; n<5000; n++)
240
         for(n=0; n<5000; n++)
239
         {
241
         {
240
            if (arena_l || arena_r) {BL; BR; delay_ms(100); goto LOOP;};
242
            if (arena_l || arena_r) {BL; BR; delay_ms(100); goto LOOP;};
Line 250... Line 252...
250
            if (sl>5) {BL; FR;};
252
            if (sl>5) {BL; FR;};
251
            if (sr>5) {FL; BR;};
253
            if (sr>5) {FL; BR;};
252
         };
254
         };
253
      }
255
      }
254
 
256
 
255
      if (f>10)      // Nepritel vpredu
257
      if (f>KOLIKRAT)      // Nepritel vpredu
256
      {
258
      {
257
         BL; FR;
259
         BL; FR;
258
         delay_ms(110);
260
         delay_ms(110);
259
         FL; BR;
261
         FL; BR;
260
         delay_ms(50);
262
         delay_ms(50);
261
         STOPL; STOPR;
263
         STOPL; STOPR;
262
      }
264
      }
263
 
265
 
264
      if (b>10)      // Nepritel vzadu
266
      if (b>KOLIKRAT)      // Nepritel vzadu
265
      {
267
      {
266
         BL; FR;
268
         BL; FR;
267
         delay_ms(110);
269
         delay_ms(110);
268
         FL; BR;
270
         FL; BR;
269
         delay_ms(50);
271
         delay_ms(50);