1 | 'Leonardo III 26.6.2009 ergoMotix(R)
|
2 |
|
3 | $regfile = "attiny24.dat"
|
4 | $crystal = 4000000
|
5 | Config Portb = Output
|
6 | Config Porta = Output 'Alle Pins werden als Ausgang definiert
|
7 |
|
8 | ' define input
|
9 | Config Pina.4 = Input 'Ein Pin (PA0) wird wieder als Eingang definiert
|
10 | Porta.4 = 1
|
11 | Config Pina.2 = Input 'Ein Pin (PA0) wird wieder als Eingang definiert.
|
12 | Porta.2 = 1 'Jumper Für K2-Betrieb
|
13 | Config Pina.7 = Input 'Interner Pullup Widerstand ein 100K
|
14 | Porta.7 = 1 'Ein Pin (PA0) wird wieder als Eingang definiert
|
15 |
|
16 |
|
17 | Dim T As Long
|
18 | T = 0
|
19 | Dim S As Bit
|
20 | S = 0
|
21 | Dim J As Bit
|
22 | 'K1 0 oder 1
|
23 | Dim J2 As Bit 'Zeitfestsetzung
|
24 | 'Lidschlag Programm
|
25 | Dim X As Long 'Zeitvariable
|
26 |
|
27 |
|
28 | ' Set I/Os
|
29 | 'Portb.0 = 0 'PB0 Pin5 K2_MOS Halbleiterreilais zbv
|
30 | 'PortA.5 = 1 'PB1 Pin6 K3_Mec Mechanisches Relais
|
31 | 'Portb.2 = 0 'PB2 Pin7 Buzzer Piezo mit integrierter Elektronik
|
32 | 'Portb.3 = 0 'PB3 Pin2 SENSOR
|
33 | 'Portb.4 = 0 'PB4 Pin3 K1_MOS Halbleiterreilais Umfeld
|
34 | 'Portb.5 = 0 'PB5 Pin1 Reset Ohne Weiteres Nicht verwendbar
|
35 | 'Pin4 GND, PIN8 VCC
|
36 |
|
37 | ' define Aliases
|
38 | K1_mos Alias Porta.3 'Zuweisung / Platzhalter
|
39 | K2_mos Alias Portb.0 'Zuweisung / Platzhalter
|
40 | K3_mec Alias Porta.5 'Zuweisung / Platzhalter
|
41 | Buzzer Alias Porta.0 'Zuweisung / Platzhalter
|
42 | Sensor Alias Pina.4
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | X = 5000
|
48 | K1_mos = 0 'Pin wird auf High, also 5V geschaltet
|
49 | K2_mos = 0 '<-
|
50 | K3_mec = 1 'Pin wird auf High, also 5V geschaltet
|
51 | Buzzer = 0 'Pin wird auf High, also 5V geschaltet
|
52 |
|
53 |
|
54 |
|
55 | 'Main_Loop_____________________________________________________________________________________________________
|
56 |
|
57 |
|
58 | Main:
|
59 |
|
60 | Do
|
61 |
|
62 | If Sensor = 1 Then
|
63 | T = T + 1
|
64 |
|
65 |
|
66 | If S = 0 Then
|
67 | If T =< 24000 Then
|
68 | K1_mos = 1 'Pin wird auf High, also 5V geschaltet
|
69 | K2_mos = 0 '<-
|
70 | K3_mec = 1
|
71 | End If
|
72 |
|
73 | Else
|
74 | If T =< 24000 Then
|
75 | K1_mos = 0 'Pin wird auf High, also 5V geschaltet
|
76 | K2_mos = 1 '<-
|
77 | K3_mec = 1
|
78 | End If
|
79 | End If 'Pin wird auf High, also 5V geschaltet
|
80 |
|
81 | If J2 = 1 Then
|
82 |
|
83 | If T = 1 Then
|
84 | Gosub Beep
|
85 | End If
|
86 |
|
87 | If T = X Then
|
88 | T = T + X
|
89 |
|
90 | Gosub Beep
|
91 |
|
92 | End If
|
93 |
|
94 | If T = X + 18000 Then
|
95 | T = T + X
|
96 | Gosub Beep
|
97 | End If
|
98 |
|
99 | If T < X + 24000 Then
|
100 | T = T + X
|
101 | If T > 18000 Then
|
102 | T = T + X
|
103 | If Sensor = 0 Then
|
104 | If J = 1 Then 'jumper nicht gesteckt, BT-Anschluß pin
|
105 | Toggle S
|
106 | End If
|
107 | End If
|
108 | End If
|
109 | End If
|
110 | End If
|
111 |
|
112 | If T > 24000 Then
|
113 | Gosub Beep
|
114 | Gosub Alarm
|
115 | Waitms 500
|
116 | End If
|
117 |
|
118 | If J2 = 0 Then
|
119 | If T = 1 Then
|
120 | Gosub Beep
|
121 | End If
|
122 |
|
123 | If T = 12000 Then
|
124 | Gosub Beep
|
125 | End If
|
126 |
|
127 | If T = 18000 Then
|
128 | Gosub Beep
|
129 | End If
|
130 |
|
131 | If T < 24000 Then
|
132 | If T > 18000 Then
|
133 | If Sensor = 0 Then
|
134 | If J = 1 Then 'jumper nicht gesteckt, BT-Anschluß pin
|
135 | Toggle S
|
136 | End If
|
137 | End If
|
138 | End If
|
139 | End If
|
140 | End If
|
141 |
|
142 | If T > 24000 Then
|
143 | Gosub Beep
|
144 | Gosub Alarm
|
145 | Waitms 500
|
146 | End If
|
147 | 'Pin wird auf High, also 5V geschaltet
|
148 | Else
|
149 | T = 0
|
150 | K1_mos = 0 'Pin wird auf Low, also 0V geschaltet
|
151 | K2_mos = 0
|
152 | K3_mec = 1 'Pin wird auf Low, also 0V geschaltet
|
153 |
|
154 | End If
|
155 |
|
156 | 'Waitms 10
|
157 |
|
158 | Loop
|
159 |
|
160 | 'Procedure Beep________________________________________________________________________________________________
|
161 |
|
162 | Beep:
|
163 |
|
164 | Buzzer = 1
|
165 | Waitms 25
|
166 | Buzzer = 0
|
167 |
|
168 | If S = 1 Then
|
169 | Waitms 25
|
170 | Buzzer = 1
|
171 | Waitms 25
|
172 | Buzzer = 0
|
173 | End If
|
174 | Return
|
175 |
|
176 |
|
177 |
|
178 | 'Procedure Alarm________________________________________________________________________________________________
|
179 |
|
180 | Alarm:
|
181 |
|
182 | K1_mos = 0 'Pin wird auf Low, also 0V geschaltet
|
183 | K2_mos = 0
|
184 | K3_mec = 0 'Pin wird auf Low, also 0V geschaltet
|
185 | Return
|
186 |
|
187 | End
|