Witam.
Napisałem program do migania diodami i mam trzy pytania:
1.Czy da się ustawić cały port w stan spoczynku (coś w stylu PORTD = 0)?
2.Czy po każdej komendzie IF trzeba pisać END IF, czy da się to jakoś ominąć?
3.Czy poniższy kod jest poprawny, czy będzie działał?
Proszę o pomoc.
Pozdrawiam Maxikaaz
Napisałem program do migania diodami i mam trzy pytania:
1.Czy da się ustawić cały port w stan spoczynku (coś w stylu PORTD = 0)?
2.Czy po każdej komendzie IF trzeba pisać END IF, czy da się to jakoś ominąć?
3.Czy poniższy kod jest poprawny, czy będzie działał?
$regfile = "attiny2313.dat"
$crystal = 8000000
Config Portb = Input
Portb = &B00000000
Config Portd = Output
Portd = &B0000000
Do
If Pinb.7 = 1 Then
Waitms 30
Toggle Portd.0
End If
If Pinb.6 = 1 Then
Waitms 30
Toggle Portd.1
End If
If Pinb.5 = 1 Then
Waitms 30
Toggle Portd.2
End If
If Pinb.4 = 1 Then
Waitms 30
Toggle Portd.3
End If
If Pinb.3 = 1 Then
Waitms 30
Toggle Portd.4
End If
If Pinb.2 = 1 Then
Waitms 30
Toggle Portd.5
End If
If Pinb.1 = 1 Then
Waitms 30
Toggle Portd.6
End If
If Pinb.0 = 1 Then
Waitms 30
Portd = 0
Portd.0 = 1
Waitms 500
Portd.0 = 0
Portd.1 = 1
Waitms 500
Portd.1 = 0
Portd.2 = 1
Waitms 500
Portd.2 = 0
Portd.3 = 1
Waitms 500
Portd.3 = 0
Portd.4 = 1
Waitms 500
Portd.4 = 0
Portd.5 = 1
Waitms 500
Portd.5 = 0
Portd.6 = 1
Waitms 500
Portd.6 = 0
Portd.7 = 1
Waitms 500
Portd.7 = 0
End If
Loop
End
Proszę o pomoc.
Pozdrawiam Maxikaaz
