Rev Author Line No. Line
2297 kakl 1 /*
2 Elektomagneticke delo
3 */
4  
5 #define LED 3
6 #define RELE 7
7 #define L1 8
8 #define L2 9
9 #define L3 10
10 #define L4 11
11 #define L5 12
12  
13 int n;
14  
15 void setup() {
16 // initialize the digital pin as an output.
17 // Pin 13 has an LED connected on most Arduino boards:
18 pinMode(LED, OUTPUT);
19 pinMode(RELE, OUTPUT);
20 pinMode(L1, OUTPUT);
21 pinMode(L2, OUTPUT);
22 pinMode(L3, OUTPUT);
23 pinMode(L4, OUTPUT);
24 pinMode(L5, OUTPUT);
25 digitalWrite(LED, HIGH);
26 digitalWrite(RELE, HIGH);
27 digitalWrite(L1, HIGH);
28 digitalWrite(L2, HIGH);
29 digitalWrite(L3, HIGH);
30 digitalWrite(L4, HIGH);
31 digitalWrite(L5, HIGH);
32 Serial.begin(9600);
33 }
34  
35 void loop() {
36  
37  
38 Serial.println("Cekam...");
39 while (Serial.available() == 0)
40 {
41 digitalWrite(LED, LOW);
42 delay(100);
43 digitalWrite(LED, HIGH);
44 delay(100);
45 }
46 digitalWrite(LED, HIGH);
47  
48 if( Serial.read()=='g')
49 {
50 Serial.println("Nabijim...");
51 digitalWrite(RELE, LOW);
52 for(n=0;n<9;n++)
53 {
54 delay(10000);
55 Serial.print(n+1, HEX);
56 Serial.println(".");
57 }
58 digitalWrite(RELE, HIGH);
59 Serial.println("Nabito.");
60 digitalWrite(LED, LOW);
61 delay(1000);
62 Serial.println("Pal.");
63 digitalWrite(LED, HIGH);
64 digitalWrite(RELE, HIGH);
65 digitalWrite(L1, LOW);
66 delayMicroseconds(1000);
67 digitalWrite(L2, LOW);
68 delayMicroseconds(100);
69 digitalWrite(L3, LOW);
70 delay(1000);
71 digitalWrite(L4, LOW);
72 delay(100);
73 digitalWrite(L5, LOW);
74 delay(100);
75 digitalWrite(L1, HIGH);
76 digitalWrite(L2, HIGH);
77 digitalWrite(L3, HIGH);
78 digitalWrite(L4, HIGH);
79 digitalWrite(L5, HIGH);
80 Serial.println("Jak to dopadlo?");
81 }
82 }