Hallo
Ich habe vor einen Taschenrechner in Bascom zu programmieren.
Als Anzeige benutze ich ein 16*2 Display.
Mein Problem ist jetzt wie ich dem Controller sage welche Zahl eingegeben wurde.
Zur Erkennung welche Rechenoperation ausgeführt werden soll(+,-,* und /) habe ich mir gedacht, weise ich einem String die Rechenoperation zu und benutze diesen um das Ergebnis dann zu berechnen.
Momentan habe ich schon die Anzeige der Zahlen programmiert.
Hier der Quellcode:
Kann mir jemand einen Denkansatz geben wie ich das Problem lösen kann?Code:$regfile = "M16def.dat" ' use the Mega16 $crystal = 1000000 Config Lcdpin = Pin , Db4 = Porta.3 , Db5 = Porta.2 , Db6 = Porta.1 , Db7 = Porta.0 , E = Porta.4 , Rs = Porta.5 Config Lcd = 16 * 2 Initlcd Config Pinb.0 = Input 'Zahl 0 Config Portb.1 = Input 'Zahl 1 Config Portb.2 = Input 'Zahl 2 Config Portb.3 = Input 'Zahl 3 Config Portb.4 = Input 'Zahl 4 Config Portd.0 = Input 'Zahl 5 Config Portd.1 = Input 'Zahl 6 Config Portd.2 = Input 'Zahl 7 Config Portd.3 = Input 'Zahl 8 Config Portd.4 = Input 'Zahl 9 Config Portd.5 = Input 'Plus Config Portd.7 = Input 'Minus Config Porta.6 = Input 'Mal Config Porta.7 = Input 'Geteilt Config Portc.7 = Input 'DELETE Config Portc.6 = Input 'AC Config Portc.5 = Input '= Config Portc.4 = Input 'Komma Config Portc.3 = Input 'Shift Config Portc.2 = Input 'x Hoch y Portb.0 = 1 'Zahl 0 Portb.1 = 1 'Zahl 1 Portb.2 = 1 'Zahl 2 Portb.3 = 1 'Zahl 3 Portb.4 = 1 'Zahl 4 Portd.0 = 1 'Zahl 5 Portd.1 = 1 'Zahl 6 Portd.2 = 1 'Zahl 7 Portd.3 = 1 'Zahl 8 Portd.4 = 1 'Zahl 9 Portd.5 = 1 'Plus Portd.7 = 1 'Minus Porta.6 = 1 'Mal Porta.7 = 1 'Geteilt Portc.7 = 1 'keine Funktion Portc.6 = 1 'AC Portc.5 = 1 '= Portc.4 = 1 'Komma Portc.3 = 1 'Shift Portc.2 = 1 'x Hoch y Dim Positionzeile As Integer Dim Positionspalte As Integer Dim Variable2 As Integer Dim Variable16 As Integer Positionzeile = 1 Positionspalte = 1 Variable2 = 2 Variable16 = 16 Do If Positionspalte > Variable16 Then Positionzeile = 2 Waitms 50 End If If Positionzeile > Variable2 Then Positionzeile = 1 Waitms 50 End If If Pinb.0 = 0 Then Cursor Off Locate Positionzeile , Positionspalte ' Zahl 0 schreiben Lcd "0" Positionspalte = Positionspalte + 1 Waitms 200 End If If Pinb.1 = 0 Then 'Zahl 1 schreiben Cursor Off Locate Positionzeile , Positionspalte Lcd "1" Positionspalte = Positionspalte + 1 Waitms 200 End If If Pinb.2 = 0 Then Cursor Off Locate Positionzeile , Positionspalte Lcd "2" Positionspalte = Positionspalte + 1 Waitms 200 End If If Pinb.3 = 0 Then Cursor Off Locate Positionzeile , Positionspalte Lcd "3" Positionspalte = Positionspalte + 1 Waitms 200 End If If Pinb.4 = 0 Then Cursor Off Locate Positionzeile , Positionspalte Lcd "4" Positionspalte = Positionspalte + 1 Waitms 200 End If If Pind.0 = 0 Then Cursor Off Locate Positionzeile , Positionspalte Lcd "5" Positionspalte = Positionspalte + 1 Waitms 200 End If If Pind.1 = 0 Then Cursor Off Locate Positionzeile , Positionspalte Lcd "6" Positionspalte = Positionspalte + 1 Waitms 200 End If If Pind.2 = 0 Then Cursor Off Locate Positionzeile , Positionspalte Lcd "7" Positionspalte = Positionspalte + 1 Waitms 200 End If If Pind.3 = 0 Then Cursor Off Locate Positionzeile , Positionspalte Lcd "8" Positionspalte = Positionspalte + 1 Waitms 200 End If If Pind.4 = 0 Then Cursor Off Locate Positionzeile , Positionspalte Lcd "9" Positionspalte = Positionspalte + 1 Waitms 200 End If If Pind.5 = 0 Then Cursor Off Locate Positionzeile , Positionspalte Lcd "+" Positionspalte = Positionspalte + 1 Waitms 200 End If If Pind.7 = 0 Then Cursor Off Locate Positionzeile , Positionspalte Lcd "-" Positionspalte = Positionspalte + 1 Waitms 200 End If If Pina.6 = 0 Then Cursor Off Locate Positionzeile , Positionspalte Lcd "x" Positionspalte = Positionspalte + 1 Waitms 200 End If If Pina.7 = 0 Then Cursor Off Locate Positionzeile , Positionspalte Lcd "/" Positionspalte = Positionspalte + 1 Waitms 200 End If If Pinc.6 = 0 Then Cls Cursor Off Positionspalte = 1 Positionzeile = 1 Waitms 200 End If
Mfg
David







Zitieren

Lesezeichen