699 |
cizelu |
1 |
#define LED1 13 |
|
|
2 |
#define LED2 12 |
|
|
3 |
#define BUMPER_L 7 |
|
|
4 |
#define BUMPER_R 8 |
|
|
5 |
#define SENZOR_L 0 |
|
|
6 |
#define SENZOR_R 1 |
|
|
7 |
|
|
|
8 |
void setup() |
|
|
9 |
{ |
|
|
10 |
Serial.begin(9600); |
|
|
11 |
pinMode(LED1, OUTPUT); |
|
|
12 |
pinMode(LED2, OUTPUT); |
|
|
13 |
pinMode(BUMPER_L, INPUT); |
|
|
14 |
pinMode(BUMPER_R, INPUT); |
|
|
15 |
digitalWrite(LED1, HIGH); |
|
|
16 |
digitalWrite(LED2, HIGH); |
|
|
17 |
Serial.print("Starting\n"); |
|
|
18 |
} |
|
|
19 |
|
|
|
20 |
void blikej() //Blika LED na pinu 12 a 13 |
|
|
21 |
{ |
|
|
22 |
} |
|
|
23 |
void diag() //Pousti DIAGNOSTIKU |
|
|
24 |
{ |
|
|
25 |
Serial.print("DIAGNOSTIKA \n"); |
|
|
26 |
while (1) |
|
|
27 |
{ |
|
|
28 |
Serial.print(analogRead(SENZOR_L)); |
|
|
29 |
Serial.print("\t"); |
|
|
30 |
Serial.print(analogRead(SENZOR_R)); |
|
|
31 |
Serial.print("\n"); |
|
|
32 |
} |
|
|
33 |
} |
|
|
34 |
|
|
|
35 |
void stopuj() //Pousti HLEDANI |
|
|
36 |
{ |
|
|
37 |
Serial.print("HLEDANI CARY \n"); |
|
|
38 |
while (1) |
|
|
39 |
{ |
|
|
40 |
|
|
|
41 |
} |
|
|
42 |
} |
|
|
43 |
|
|
|
44 |
void loop() //HLAVNI SMYCKA |
|
|
45 |
{ |
|
|
46 |
blikej(); |
|
|
47 |
if(digitalRead(BUMPER_L) == 1) //diagnostika |
|
|
48 |
{ |
|
|
49 |
digitalWrite(LED1, LOW); |
|
|
50 |
diag(); |
|
|
51 |
} |
|
|
52 |
if(digitalRead(BUMPER_R) == 1) //stopar |
|
|
53 |
{ |
|
|
54 |
digitalWrite(LED2, LOW); |
|
|
55 |
stopuj(); |
|
|
56 |
} |
|
|
57 |
} |