Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'sterownik bramy
- 'S1 wlacza brame
- 'po jakims czasie nie widzac przeszkody
- 'brama sama sie zamyka
- 'napisal Kamil Nowinski
- 'NIE TESTOWANE SPRZETOWO!
- $regfile = "m8def.dat"
- $crystal = 4000000
- Config Adc = Single , Prescaler = Auto , Reference = Avcc
- Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down
- 'konfiguracja portow we/wy
- Config Portd.0 = Input 'przycisk S1
- Config Portd.1 = Output
- Config Portd.2 = Output
- Config Portd.3 = Output
- Config Portd.4 = Output
- Config Portd.5 = Output
- Config Portd.6 = Output
- Config Portd.7 = Output
- Config Portb = Output
- 'Aliasy
- S1 Alias Pind.0
- Dioda_z Alias Pind.1 'zielona kontrolka
- Dioda_c Alias Pind.2 'czerwona kontrolka
- Silnik_a Alias Pind.3 'prawe obroty
- Silnik_b Alias Pind.4 'lewe obroty
- Dim Czujnik_a As Single '5
- Dim Czujnik_b As Single '4
- Dim Czujnik_c As Single '3
- Dim Czujnik_d As Single 'krancowka
- Dim Czujnik_e As Single
- Dim K As Word
- Dim A As Word
- Dim M As Word
- Dim I As Word
- Dim L As Word
- Const Granica = 500 'dobrac doswiadczalnie
- 'stany przy spoczynku
- Set S1
- Set Dioda_z
- Reset Dioda_c 'czerwona kontrolka
- 'w stanie spoczynkowym sie pali
- Set Silnik_a
- Set Silnik_b
- Start Adc
- Do
- K = Getadc(5)
- K = Getadc(5)
- Stop Adc
- Czujnik_a = K
- Start Adc
- A = Getadc(4)
- A = Getadc(4)
- Stop Adc
- Czujnik_b = A
- Start Adc
- M = Getadc(3)
- M = Getadc(3)
- Stop Adc
- Czujnik_c = M
- If Czujnik_a > Granica Or Czujnik_b > Granica Or Czujnik_c > Granica Then
- Pwm1a = 255
- Pwm1b = 0 'brama sie otwiera
- Start Adc
- I = Getadc(2)
- I = Getadc(2)
- Stop Adc
- Czujnik_d = I
- End If
- If Czujnik_d > Granica Or Czujnik_e > Granica Then
- Pwm1a = 255 'brama stopuje
- Pwm1b = 255
- wait 5
- End If
- If Czujnik_a < Granica Or Czujnik_b < Granica Or Czujnik_c < Granica Then
- Pwm1a = 0 'brama sie zamyka
- Pwm1b = 255
- Start Adc
- L = Getadc(1)
- L = Getadc(1)
- Stop Adc
- Czujnik_e = L
- End If
- Loop
- End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement