umrechnen?
entweder gibts in der Sprach die du codest schon ne fertige Funktion oder du musst das selber machen
Hallo!
Ich möchte gerne ein Port am LCD darsetellen, aber im DualSystem, so dass LCD-Anzeige "Port A= 00010000" zum Beispiel anzeigt. Wie kriege ich es hin?
Ich konfiguriere PortA als Input, deklariere Variable X als Byte, Weise X mit X=Pina den Wert zu, und gebe X mit LCD X auf LCD aus.
Nur der Wert wird als Dezimal-Zahl angezeigt, und ich möchte es gerne Dual haben.
bis dann,
Nico
umrechnen?
entweder gibts in der Sprach die du codest schon ne fertige Funktion oder du musst das selber machen
Hallo Nico!
Vielleicht hilft dir dieses Programm weiter:
Habe es aber nur im Simulator getestet, dort funktionierte es aber!Code:$regfile = "m16def.dat" $crystal = 8000000 $baud = 9600 Config Lcd = 16 * 2 Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2 Dim Porta_zustand As Byte Porta_zustand = 0 Config Porta = Output Porta = 255 Initlcd Cls Do Porta = Porta_zustand Upperline Lcd Porta_zustand Lowerline Lcd Bin(porta_zustand) Incr Porta_zustand Loop End
Grüße,
Jonas
Es funktioniert auf jeden Fall mit Print Bin in BASCOM. (255 = 11111111)
Warum also nicht auch mit dem LCD.
Notfalls (wenn alle Stricke reissen) vorher in einen String umwandeln und dann an das LCD senden.
Hier die Umwandlung in den String Text, welcher dann an das LCD gesendet werden kann.Code:$regfile = "m16def.dat" $crystal = 8000000 $baud = 9600 Dim Porta_zustand As Byte Dim X As Byte Porta_zustand = 0 Config Porta = Output Porta = 255 For X = 0 To 255 Porta_zustand = X Print Porta_zustand Print Bin(porta_zustand) Incr Porta_zustand Next X End
Code:$regfile = "m16def.dat" $crystal = 8000000 $baud = 9600 Dim Text As String * 16 Dim Porta_zustand As Byte Dim X As Byte Porta_zustand = 0 Config Porta = Output Porta = 255 For X = 0 To 255 Porta_zustand = X Text = Bin(x) Print Porta_zustand; Print " "; Print Bin(porta_zustand); Print " "; Print "["; Print Text; Print "]" Next X End
Gruss
Darwin (meine Projekte sind auf meiner Pinnwand zu finden)
Lesezeichen