' Oster-Contest, 11-Seg.-Motorrad-Ganganzeige, 78L05 nicht vergessen
' wie 7-Seg-Anzeige mit zusätzlichen Ecken-LED (7+4=11)
'-------------------------------------------------------------------------------
' _____
' |78 05|
' +12V o----|>|--o-|_____|-o-----------o +5V
' 1N4148 | | |
' --- | ---
' 100nF --- | --- 100nF
' | | |
' GND o---------o----o----o-----------o GND
'
' (100nF)
' o--| |--o-------o Reset
' / | ___ | ___
' Neutral |--o o--|<|-----o-|___|-o-|___|-o +5V
' 1N4148 (10k) 1k2
' /
' Reed-up |--o o--|<|-------------o-------o PB.4/ADC(2)
' / 1N4148 ___ | ___
' Reed-Down |--o o--|<|-------|___|-o-|___|-o +5V
' 1N4148 1k2 1k2
'
' o----------o----------o----------o-------o PB.3
' | | | ___ |
' o--|<|--o o--|<|--o o--|<|--o o-|___|-o
' | L81 | L82 | L84 | >120R
' | o--|-------o--|-------o--|-------o-------o PB.2
' | | | | | ___ | | |
' o--|<|--o o--|<|--o o-|___|-o o--|<|--o
' | L41 | L42 | >120R | L48
' | o--|-------o--|-------o--|-------o-------o PB.1
' | | | ___ | | | | |
' o--|<|--o o-|___|-o o--|<|--o o--|<|--o
' | L21 | >120R | L24 | L28
' | o--|-------o--|-------o--|-------o-------o PB.0
' | ___ | | | | | | |
' o-|___|-o o--|<|--o o--|<|--o o--|<|--o
' >120R L12 L14 L18
'
' Steuerung der bis zu 3 LED:
' Reihe PB.0, L12: PortB=1; DDRB=1+2
' " L18: " ; DDRB=1+8
' usw.
' Reihe PB.3, L84: PortB=8; DDRB=8+4
' " L81+L82+L84: " ; DDRB=8+1+2+4
'
' L81 L82 L84
'
' L41 (L42) L48
' L24
' L21 L28
'
' L12 L14 L18
'
'-------------------------------------------------------------------------------
' alle Fuse-Byte ab Werk
'-------------------------------------------------------------------------------
$regfile = "attiny13.dat"
$crystal = 1200000 ' 9,6MHz/8
$hwstack = 8
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Dim Gang As Byte 'state
Dim Gangmax As Byte
Dim Reed As Word 'up/down
Dim Old As Word
Gangmax = 6 'getriebe
Do 'Hauptprogramm
Main:
Old = Reed : Reed = Getadc(2)
If Reed >= 768 Then Goto Anzeige
If Old < 768 Then Goto Anzeige
If Gang = 0 Then Gang = 1
If Reed < 256 Then '<256=down
If Gang >= 2 Then Gang = Gang - 1
Else '256-768=up
If Gang < Gangmax Then Gang = Gang + 1
End If
Anzeige:
If Gang = 0 Then :
Ddrb = &B1111 : Portb = 1 : Waitms 3 :
Ddrb = &B1011 : Portb = 2 : Waitms 3 :
Ddrb = &B1101 : Portb = 4 : Waitms 3 :
Ddrb = &B1111 : Portb = 8 : Waitms 3 : End If
If Gang = 1 Then :
Ddrb = &B1001 : Portb = 1 : Waitms 3 :
Ddrb = &B1010 : Portb = 2 : Waitms 3 :
Ddrb = &B1100 : Portb = 4 : Waitms 3 :
Ddrb = &B1100 : Portb = 8 : Waitms 3 : End If
If Gang = 2 Then :
Ddrb = &B1111 : Portb = 1 : Waitms 3 :
Ddrb = &B0111 : Portb = 2 : Waitms 3 :
Ddrb = &B1100 : Portb = 4 : Waitms 3 :
Ddrb = &B1111 : Portb = 8 : Waitms 3 : End If
If Gang = 3 Then :
Ddrb = &B1111 : Portb = 1 : Waitms 3 :
Ddrb = &B1110 : Portb = 2 : Waitms 3 :
Ddrb = &B1100 : Portb = 4 : Waitms 3 :
Ddrb = &B1111 : Portb = 8 : Waitms 3 : End If
If Gang = 4 Then :
Ddrb = &B1001 : Portb = 1 : Waitms 3 :
Ddrb = &B1110 : Portb = 2 : Waitms 3 :
Ddrb = &B1101 : Portb = 4 : Waitms 3 :
Ddrb = &B1101 : Portb = 8 : Waitms 3 : End If
If Gang = 5 Then :
Ddrb = &B1111 : Portb = 1 : Waitms 3 :
Ddrb = &B1110 : Portb = 2 : Waitms 3 :
Ddrb = &B0101 : Portb = 4 : Waitms 3 :
Ddrb = &B1111 : Portb = 8 : Waitms 3 : End If
If Gang = 6 Then :
Ddrb = &B1111 : Portb = 1 : Waitms 3 :
Ddrb = &B1111 : Portb = 2 : Waitms 3 :
Ddrb = &B0101 : Portb = 4 : Waitms 3 :
Ddrb = &B1111 : Portb = 8 : Waitms 3 : End If
Loop
' End Program