@Matthias
Auch wenn dein Programm jetzt funktioniert, habe ich die trotzdem mal ein Programm geschrieben wo du sehen kannst wie man so was macht.
Ich muß ehrlich sagen als ich dein Programm gesehen habe standen mir die Haare zu Berg.
mfg GuyCode:$regfile = "8515def.dat" Dim I As Integer Dim Schalter1an As Bit Dim Schalter2an As Bit Dim Bytetemp As Byte Config Pina.0 = Input Config Portb = Output Config Portc = Output Portb = 0 Portc = 0 Do ' lampen 1 If Pina.0 = 1 Then If Schalter1an = 1 Then If Portb = 255 Then Schalter1an = 0 End If Else If Portb = 0 Then Schalter1an = 1 End If End If While Pina.0 = 1 ' WARTEN BIS TASTE WIDER LOSGELASSEN Wend End If ' end lampen 1 ' lampen 2 If Pina.1 = 1 Then If Schalter2an = 1 Then If Portc = 255 Then Schalter2an = 0 End If Else If Portc = 0 Then Schalter2an = 1 End If End If While Pina.1 = 1 ' WARTEN BIS TASTE WIDER LOSGELASSEN Wend End If ' end lampen 2 ' lampen 1 If Schalter1an = 1 And Portb <> 255 Then Bytetemp = Portb Bytetemp = Bytetemp + 1 Portb = Portb Or Bytetemp End If If Schalter1an = 0 And Portb <> 0 Then Shift Portb , Right ' Shift Portb , Left ' anders rum End If ' end lampen 1 ' lampen 2 If Schalter2an = 1 And Portc <> 255 Then Bytetemp = Portc Bytetemp = Bytetemp + 1 Portc = Portc Or Bytetemp End If If Schalter2an = 0 And Portc <> 0 Then Shift Portc , Right ' Shift Portc , Left ' anders rum End If ' end lampen 2 For I = 1 To 5 'Die for Schleife ist nur beim Simulator notwendig, weil der wait befehl mit der LCD Anzeige im Simulator nicht funktioniert. 'Also wenn fertig Schleife durch Wait ersetzen. ' Waitms 0.1 Next I Loop
Edit
Hier noch ein Beispiel wie du zum Beispiel die Lampen auch ausschalten kannst.
Mußt dich mal mit binär rechen abgeben. Als Beispiel, bei einer Binärzahl verschiebst du durch Division alles nach Rechts, und durch Multiplikation alles nach links.Code:If Schalter1an = 0 And Portb <> 0 Then ' Shift Portb , Right ' Shift Portb , Left ' anders rum Portb = Portb / 2 End If







Zitieren

Lesezeichen