Hallo zusammen,
mit diesem kleinen Projektle (wie der Schwabe sagt) möchte ich mich bei Euch bedanken.
Dank dem Forum und dem RN-Wissen konnte ich mir das nötige Wissen aneignen, um mein erstes kleinen Projekt zu realisieren.
Bescheibung:
Platine mit 15 Low Current LED´s, 3 Tastern und einem Batteriehalterung.
Mit den Tastern können unterschiedliche LED Lauflichtprogramme durchgewechselt werden.
Schaltung und Platinelayout wurde mit Target!3000 V15 Light gezeichnet.
Das Programm wurde mit Bascom programmiert.
Quellcode:
Code:
'****************************************************************************
'* Filename : ATMEGA8 15 Kanal Lauflicht unterschiedl. Programme *
'* Revision : 1.0 *
'* Controller : ATMEGA8 *
'* Compiler : BASCOM-AVR 1.11.9.5 *
'* Author : Stefan Kobsa, SteKo Software, 2013 *
'* WWW : http://www.steko-software.de *
'****************************************************************************
'------------------------------------------------------------------------------
$regfile = "m8def.dat" ' ATMEGA8
$crystal = 16000000 '
$baud = 19200
$hwstack = 40
$swstack = 20
$framesize = 20
'Dynamisch Pause Gewschwindigkeit einstellen
Dim Pause As Integer
Pause = 100 '1 Sekunde
Dim Proglicht As Integer
Dim Progmax As Integer
Proglicht = 18
Progmax = 18
' LED Ports definieren
Led1 Alias Portd.5 'GRÜN rechts
Config Pind.5 = Output
Led2 Alias Portd.6 'ROT
Config Pind.6 = Output
Led3 Alias Portd.7 'ROT
Config Pind.7 = Output
Led4 Alias Portb.0 'ROT
Config Pinb.0 = Output
Led5 Alias Portb.1 'GELB
Config Pinb.1 = Output
Led6 Alias Portb.2 'GELB
Config Pinb.2 = Output
Led7 Alias Portb.3 'GELB
Config Pinb.3 = Output
Led8 Alias Portb.4 'GRÜN mitte
Config Pinb.4 = Output
Led9 Alias Portb.5 'GELB
Config Pinb.5 = Output
Led10 Alias Portc.0 'GELB
Config Pinc.0 = Output
Led11 Alias Portc.1 'GELB
Config Pinc.1 = Output
Led12 Alias Portc.2 'ROT
Config Pinc.2 = Output
Led13 Alias Portc.3 'ROT
Config Pinc.3 = Output
Led14 Alias Portc.4 'ROT
Config Pinc.4 = Output
Led15 Alias Portc.5 'GRÜN links
Config Pinc.5 = Output
'Taster definieren
Wechsel Alias Pind.2
Config Pind.2 = Input
Portd.2 = 1 'PullUp-Widerstand einschalten
Schneller Alias Pind.3
Config Pind.3 = Input
Portd.3 = 1 'PullUp-Widerstand einschalten
Langsamer Alias Pind.4
Config Pind.4 = Input
Portd.4 = 1 'PullUp-Widerstand einschalten
Reset Led1
Reset Led2
Reset Led3
Reset Led4
Reset Led5
Reset Led6
Reset Led7
Reset Led8
Reset Led9
Reset Led10
Reset Led11
Reset Led12
Reset Led13
Reset Led14
Reset Led15
Declare Sub Led_alle(byval Status As Integer)
Declare Sub Led_alle_gruen(byval Status As Integer)
Declare Sub Led_alle_rot(byval Status As Integer)
Declare Sub Led_alle_gelb(byval Status As Integer)
Declare Sub Machpause
Declare Sub Tasterabfrage
Print "SteKo Software - 15 LED Lauflicht mit 3 Tastern steuern"
Print "Programm wird gestartet!"
'Initiallisieren LED Test
Call Led_alle(1)
Waitms 2000
Call Led_alle(0)
Do ' Hauptprogramm Schleife
'
Startprog:
Select Case Proglicht
Case 1 'alle Lichter an aus
Call Machpause
Call Led_alle(0)
Call Machpause
Call Led_alle(1)
Case 2 'alle grünen Lichter an aus
Call Machpause
Call Led_alle_gruen(0)
Call Machpause
Call Led_alle_gruen(1)
Case 3 'alle rot Lichter an aus
Call Machpause
Call Led_alle_rot(0)
Call Machpause
Call Led_alle_rot(1)
Case 4 'alle gelb Lichter an aus
Call Machpause
Call Led_alle_gelb(0)
Call Machpause
Call Led_alle_gelb(1)
Case 5 'LED alle Rot Gelb im wechsel
Call Machpause
Call Led_alle(0)
Call Led_alle_rot(1)
Call Machpause
Call Led_alle_rot(0)
Call Led_alle_gelb(1)
Case 6 'LED alle Rot Grün im wechsel
Call Machpause
Call Led_alle(0)
Call Led_alle_rot(1)
Call Machpause
Call Led_alle_rot(0)
Call Led_alle_gruen(1)
Case 7 'LED alle Grün Gelb im wechsel
Call Machpause
Call Led_alle(0)
Call Led_alle_gruen(1)
Call Machpause
Call Led_alle_gruen(0)
Call Led_alle_gelb(1)
Case 8 'Lichter von rechts nach links
Call Led_alle(0)
Call Machpause
Led1 = 1
Call Machpause
Led2 = 1
Call Machpause
Led3 = 1
Call Machpause
Led4 = 1
Call Machpause
Led5 = 1
Call Machpause
Led6 = 1
Call Machpause
Led7 = 1
Call Machpause
Led8 = 1
Call Machpause
Led9 = 1
Call Machpause
Led10 = 1
Call Machpause
Led11 = 1
Call Machpause
Led12 = 1
Call Machpause
Led13 = 1
Call Machpause
Led14 = 1
Call Machpause
Led15 = 1
Call Machpause
Led1 = 0
Call Machpause
Led2 = 0
Call Machpause
Led3 = 0
Call Machpause
Led4 = 0
Call Machpause
Led5 = 0
Call Machpause
Led6 = 0
Call Machpause
Led7 = 0
Call Machpause
Led8 = 0
Call Machpause
Led9 = 0
Call Machpause
Led10 = 0
Call Machpause
Led11 = 0
Call Machpause
Led12 = 0
Call Machpause
Led13 = 0
Call Machpause
Led14 = 0
Call Machpause
Led15 = 0
Call Machpause
Case 9 'Lichter von links nach rechts
Call Led_alle(0)
Call Machpause
Led15 = 1
Call Machpause
Led14 = 1
Call Machpause
Led13 = 1
Call Machpause
Led12 = 1
Call Machpause
Led11 = 1
Call Machpause
Led10 = 1
Call Machpause
Led9 = 1
Call Machpause
Led8 = 1
Call Machpause
Led7 = 1
Call Machpause
Led6 = 1
Call Machpause
Led5 = 1
Call Machpause
Led4 = 1
Call Machpause
Led3 = 1
Call Machpause
Led2 = 1
Call Machpause
Led1 = 1
Call Machpause
Led15 = 0
Call Machpause
Led14 = 0
Call Machpause
Led13 = 0
Call Machpause
Led12 = 0
Call Machpause
Led11 = 0
Call Machpause
Led10 = 0
Call Machpause
Led9 = 0
Call Machpause
Led8 = 0
Call Machpause
Led7 = 0
Call Machpause
Led6 = 0
Call Machpause
Led5 = 0
Call Machpause
Led4 = 0
Call Machpause
Led3 = 0
Call Machpause
Led2 = 0
Call Machpause
Led1 = 0
Call Machpause
Case 10 'eine LED von rechts nach links
Call Machpause
Call Led_alle(0)
Led15 = 0
Led1 = 1
Call Machpause
Led1 = 0
Led2 = 1
Call Machpause
Led2 = 0
Led3 = 1
Call Machpause
Led3 = 0
Led4 = 1
Call Machpause
Led4 = 0
Led5 = 1
Call Machpause
Led5 = 0
Led6 = 1
Call Machpause
Led6 = 0
Led7 = 1
Call Machpause
Led7 = 0
Led8 = 1
Call Machpause
Led8 = 0
Led9 = 1
Call Machpause
Led9 = 0
Led10 = 1
Call Machpause
Led10 = 0
Led11 = 1
Call Machpause
Led11 = 0
Led12 = 1
Call Machpause
Led12 = 0
Led13 = 1
Call Machpause
Led13 = 0
Led14 = 1
Call Machpause
Led14 = 0
Led15 = 1
Case 11 'eine LED von Links nach Rechts
Call Led_alle(0)
Call Machpause
Led1 = 0
Led15 = 1
Call Machpause
Led15 = 0
Led14 = 1
Call Machpause
Led14 = 0
Led13 = 1
Call Machpause
Led13 = 0
Led12 = 1
Call Machpause
Led12 = 0
Led11 = 1
Call Machpause
Led11 = 0
Led10 = 1
Call Machpause
Led10 = 0
Led9 = 1
Call Machpause
Led9 = 0
Led8 = 1
Call Machpause
Led8 = 0
Led7 = 1
Call Machpause
Led7 = 0
Led6 = 1
Call Machpause
Led6 = 0
Led5 = 1
Call Machpause
Led5 = 0
Led4 = 1
Call Machpause
Led4 = 0
Led3 = 1
Call Machpause
Led3 = 0
Led2 = 1
Call Machpause
Led2 = 0
Led1 = 1
Case 12 'LED rechts links laufen
Call Machpause
Call Led_alle(0)
Led15 = 0
Led1 = 1
Call Machpause
Led1 = 0
Led2 = 1
Call Machpause
Led2 = 0
Led3 = 1
Call Machpause
Led3 = 0
Led4 = 1
Call Machpause
Led4 = 0
Led5 = 1
Call Machpause
Led5 = 0
Led6 = 1
Call Machpause
Led6 = 0
Led7 = 1
Call Machpause
Led7 = 0
Led8 = 1
Call Machpause
Led8 = 0
Led9 = 1
Call Machpause
Led9 = 0
Led10 = 1
Call Machpause
Led10 = 0
Led11 = 1
Call Machpause
Led11 = 0
Led12 = 1
Call Machpause
Led12 = 0
Led13 = 1
Call Machpause
Led13 = 0
Led14 = 1
Call Machpause
Led14 = 0
Led15 = 1
Call Machpause
Led15 = 0
Led14 = 1
Call Machpause
Led14 = 0
Led13 = 1
Call Machpause
Led13 = 0
Led12 = 1
Call Machpause
Led12 = 0
Led11 = 1
Call Machpause
Led11 = 0
Led10 = 1
Call Machpause
Led10 = 0
Led9 = 1
Call Machpause
Led9 = 0
Led8 = 1
Call Machpause
Led8 = 0
Led7 = 1
Call Machpause
Led7 = 0
Led6 = 1
Call Machpause
Led6 = 0
Led5 = 1
Call Machpause
Led5 = 0
Led4 = 1
Call Machpause
Led4 = 0
Led3 = 1
Call Machpause
Led3 = 0
Led2 = 1
Call Machpause
Led2 = 0
Case 13 'LED aus der Mitte immer mehr an
Call Machpause
Call Led_alle(0)
Led8 = 1
Call Machpause
Led7 = 1
Led9 = 1
Call Machpause
Led6 = 1
Led10 = 1
Call Machpause
Led5 = 1
Led11 = 1
Call Machpause
Led4 = 1
Led12 = 1
Call Machpause
Led3 = 1
Led13 = 1
Call Machpause
Led2 = 1
Led14 = 1
Call Machpause
Led1 = 1
Led15 = 1
Case 14 'LED von links und rechts in die Mitte
Call Machpause
Call Led_alle(0)
Led15 = 1
Led1 = 1
Call Machpause
Led14 = 1
Led2 = 1
Call Machpause
Led13 = 1
Led3 = 1
Call Machpause
Led12 = 1
Led4 = 1
Call Machpause
Led11 = 1
Led5 = 1
Call Machpause
Led10 = 1
Led6 = 1
Call Machpause
Led9 = 1
Led7 = 1
Call Machpause
Led8 = 1
Case 15 'LED rechts links Mitte aus
Call Machpause
Call Led_alle(0)
Led1 = 1
Led2 = 1
Led3 = 1
Led4 = 1
Led5 = 1
Led6 = 1
Led7 = 1
Call Machpause
Call Led_alle(0)
Led8 = 1
Led9 = 1
Led10 = 1
Led11 = 1
Led12 = 1
Led13 = 1
Led14 = 1
Led15 = 1
Case 16 'LED rechts links nur Grün
Call Machpause
Call Led_alle(0)
Led1 = 1
Call Machpause
Call Led_alle(0)
Led15 = 1
Case 17 'LED rechts links nur Rot
Call Machpause
Call Led_alle(0)
Led2 = 1
Led3 = 1
Led4 = 1
Call Machpause
Call Led_alle(0)
Led12 = 1
Led13 = 1
Led14 = 1
Case 18 'LED rechts links nur Gelb
Call Machpause
Call Led_alle(0)
Led5 = 1
Led6 = 1
Led7 = 1
Call Machpause
Call Led_alle(0)
Led9 = 1
Led10 = 1
Led11 = 1
End Select
Loop
End
Sub Led_alle(byval Status As Integer)
'Call Tasterabfrage ' wurde eine Taste gedrückt?
If Status = 1 Then 'Alle LED anschalten
Print "Alle LED AN"
Led1 = 1 'GRÜN rechts
Led2 = 1 'ROT
Led3 = 1 'ROT
Led4 = 1 'ROT
Led5 = 1 'GELB
Led6 = 1 'GELB
Led7 = 1 'GELB
Led8 = 1 'GRÜN mitte
Led9 = 1 'GELB
Led10 = 1 'GELB
Led11 = 1 'GELB
Led12 = 1 'ROT
Led13 = 1 'ROT
Led14 = 1 'ROT
Led15 = 1 'GRÜN links
Else
Print "Alle LED AUS"
Led1 = 0 'GRÜN rechts
Led2 = 0 'ROT
Led3 = 0 'ROT
Led4 = 0 'ROT
Led5 = 0 'GELB
Led6 = 0 'GELB
Led7 = 0 'GELB
Led8 = 0 'GRÜN mitte
Led9 = 0 'GELB
Led10 = 0 'GELB
Led11 = 0 'GELB
Led12 = 0 'ROT
Led13 = 0 'ROT
Led14 = 0 'ROT
Led15 = 0 'GRÜN links
End If
End Sub
Sub Led_alle_gruen(byval Status As Integer) ' Alle grünen LED betreffend
'Call Tasterabfrage ' wurde eine Taste gedrückt?
Call Led_alle(0)
If Status = 1 Then 'Alle LED anschalten
Print "Alle LED gruen AN"
Led1 = 1 'GRÜN rechts
Led8 = 1 'GRÜN mitte
Led15 = 1 'GRÜN links
Else
Print "Alle LED gruen AUS"
Led1 = 0 'GRÜN rechts
Led8 = 0 'GRÜN mitte
Led15 = 0 'GRÜN links
End If
End Sub
Sub Led_alle_rot(byval Status As Integer)
'Call Tasterabfrage ' wurde eine Taste gedrückt?
Call Led_alle(0)
If Status = 1 Then 'Alle LED anschalten
Print "Alle LED rot AUS"
Led2 = 1 'ROT
Led3 = 1 'ROT
Led4 = 1 'ROT
Led12 = 1 'ROT
Led13 = 1 'ROT
Led14 = 1 'ROT
Else
Print "Alle LED rot AUS"
Led2 = 0 'ROT
Led3 = 0 'ROT
Led4 = 0 'ROT
Led12 = 0 'ROT
Led13 = 0 'ROT
Led14 = 0 'ROT
End If
End Sub
Sub Led_alle_gelb(byval Status As Integer)
'Call Tasterabfrage ' wurde eine Taste gedrückt?
Call Led_alle(0)
If Status = 1 Then 'Alle LED anschalten
Print "Alle LED gelb AN"
Led5 = 1 'GELB
Led6 = 1 'GELB
Led7 = 1 'GELB
Led9 = 1 'GELB
Led10 = 1 'GELB
Led11 = 1 'GELB
Else
Print "Alle LED gelb AUS"
Led5 = 0 'GELB
Led6 = 0 'GELB
Led7 = 0 'GELB
Led9 = 0 'GELB
Led10 = 0 'GELB
Led11 = 0 'GELB
End If
End Sub
Sub Machpause
Call Tasterabfrage ' wurde eine Taste gedrückt?
Waitms Pause
End Sub
Sub Tasterabfrage
'schneller, langsamer
If Pind.2 = 0 Then
If Proglicht < Progmax Then
Proglicht = Proglicht + 1
Else
Proglicht = 1
End If
Print "Programm: " ; Proglicht
End If
'Programm wechsel
If Pind.3 = 0 Then
Pause = Pause - 5
Print "Schneller: " ; Pause
End If
'Langsamer
If Pind.4 = 0 Then
Pause = Pause + 20
Print "Langsamer: " ; Pause
End If
If Pause <= 0 Then Pause = 10
End Sub
Schaltung:
(Die LED14 und LED15 fehlen oben, wegen Screenshot)
Platinen Layout:
Platine in Target!3000 als 3D vorab:
Platine bestückt und durch Isolationsfräsen erzeugt:
Lesezeichen