Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $regfile = "m8def.dat"
- $crystal = 1000000
- Config Portb = &B011111111 : Portb = &B00000000
- Config Portc = &B00000000 : Portc = &B00000000
- Config Portd = &B11111101
- Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up
- Config Pind.1 = Input
- Config Portd.7 = Output 'mostek
- Config Portd.6 = Output 'mostek
- Config Portd.5 = Output 'mostek
- Config Portd.4 = Output 'mostek
- Mset1b Alias Portd.4
- Mset1a Alias Portd.5
- Mset2a Alias Portd.6
- Mset2b Alias Portd.7
- Dioda_zielona Alias Portd.2
- Dioda_czerwona Alias Portd.3
- Przycisk Alias Pind.1
- Dim Tcrt1 As Word 'prawy czujnik linii (patrzac na tyl robota)
- Dim Tcrt2 As Word
- Dim V1 As Byte
- Dim V2 As Byte
- Pwm1a = 0 'silnik prawy (patrząc na tyl robota) - wypelnienie PWM
- Pwm1b = 0
- Dim Flag As Byte
- Set Dioda_czerwona
- Set Dioda_zielona
- Do
- Waitms 200
- If Przycisk = 0 Then
- Flag = 1
- Set Dioda_zielona
- End If
- If Flag = 1 Then
- Set Dioda_czerwona
- Gosub Odczytadc
- Set Mset1a : Reset Mset1b
- Set Mset2a : Reset Mset2b
- Pwm1a = V1
- Pwm1b = V2
- Waitms 500
- End If
- Reset Dioda_zielona
- Reset Dioda_czerwona
- Loop
- End
- Odczytadc:
- Start Adc
- Tcrt1 = Getadc(2) 'PC.2
- Tcrt2 = Getadc(3)
- If Tcrt1 > 255 Then
- V1 = 255
- Else
- V1 = Tcrt1
- End If
- If Tcrt2 > 255 Then
- V2 = 255
- Else
- V2 = Tcrt2
- End If 'PC.3
- Stop Adc
- Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement