Das mit der Masse war so, weil der Widerstand einfach zu gross war das funktioniert jetzt und mehr als 5V hab ich so oder so nicht, also von daher keine gefahr. Ich hab das ganze nicht so aufgebaut wie auf dem Applikation board, sondern einfach jede Taste mit einem anderen Widerstand versehen. Vom Prinzip also gleich aber anders aufgebaut.
Das mit dem Störfeld ist ein guter Tipp, denn ich bin fast verzweifelt als das ding im Wohnzimmer immer gepiept hat und bei mir im Zimmer Problemlos lief. Lag wohl an der Fussbodenheizung. Muss mal schauen obs immernoch Probleme gibt. Hab so langsam keine Lust mehr zu conrad zu laufenaber ich werds mir auf jeden Fall merken.
Was deinen Code angeht.... ich glaube ich hab schonmal gesagt das ich nich so der klasse Programierer bin, also so wird ein code bei mir nie aussehen. Solang ichs hingrieg bin ich mit meinem trotzdem recht zufrieden. kannst dir ja ma angucken was ich da verbockt hab. fehlt eigentlich nur noch die ausgabe aufs LCD.
das schwierigste war für mich den TOG befehl auf PORTS des PCF8574 umzusetzen. Ich löse sowas immer auf eine komische Art die dann recht undurchschaubar aussieht.... hoffe es ist nich all zu doof ProgramiertCode:DEFINE PCFAdresse Byte[1] 'erste sein! Bytevar $0A1 DEFINE PCFDaten Byte[2] 'zweite sein!Bytevar $0a2 DEFINE Preset02 BYTE DEFINE Preset12 BYTE DEFINE Preset22 BYTE DEFINE Preset32 BYTE DEFINE Preset42 BYTE DEFINE Preset52 BYTE DEFINE Preset62 BYTE DEFINE Preset72 BYTE DEFINE Preset82 BYTE DEFINE Preset92 BYTE DEFINE NR BYTE DEFINE NR2 BYTE DEFINE key BYTE DEFINE Preset01 WORD DEFINE Preset11 WORD DEFINE Preset21 WORD DEFINE Preset31 WORD DEFINE Preset41 WORD DEFINE Preset51 WORD DEFINE Preset61 WORD DEFINE Preset71 WORD DEFINE Preset81 WORD DEFINE Preset91 WORD DEFINE Ports1 WORDPORT[1] DEFINE key2 AD[6] DEFINE L01 port[1] DEFINE L02 port[2] DEFINE L03 port[3] DEFINE L04 port[4] DEFINE L05 port[5] DEFINE L06 port[6] DEFINE L07 port[7] DEFINE L08 port[8] DEFINE L09 port[9] DEFINE L10 port[10] DEFINE L11 port[11] DEFINE L12 port[12] DEFINE L13 port[13] DEFINE L14 Port[14] DEFINE L15 Port[15] DEFINE L16 Port[16] DEFINE a 97 DEFINE b 98 DEFINE c 99 DEFINE d 100 DEFINE e 101 DEFINE f 102 DEFINE g 103 DEFINE h 104 DEFINE i 105 DEFINE j 106 DEFINE k 107 DEFINE l 108 DEFINE m 109 DEFINE n 110 DEFINE o 111 DEFINE p 112 DEFINE q 113 DEFINE r 114 DEFINE s 115 DEFINE t 116 DEFINE u 117 DEFINE v 118 DEFINE w 119 DEFINE x 120 DEFINE y 121 DEFINE z 122 #AllOff Ports1 = OFF #start GOSUB Eingabe if NR2 = 0 and NR = 0 then goto AllOff 'Alle ausschalten if NR2 > 9 and NR < 10 then goto error 'Nur zweistellige Zahlen zulassen if NR = 11 then goto menu1 'Menü Laden/Speichern aufrufen if NR2 <> 0 And NR = 12 then goto schalten 'Bei Korrekter Eingabe schalten if NR2 = 0 And NR = 12 then goto error 'Enter ohne Eingabe -> Error if NR2 = 0 then goto Ziffer1 'Zwischenspeicher leer -> erste Stelle zwischenspeichern NR2 = NR + NR2 * 10 'zweite Stelle Berechnen goto start #Ziffer1 NR2 = NR 'erste stelle zwischenspeichern goto start #reset NR2 = 0 'zwischenspeicher löschen goto start #error beep 400,25,10 goto reset #schalten if NR2 = 1 then TOG L01 if NR2 = 2 then TOG L02 if NR2 = 3 then TOG L03 if NR2 = 4 then TOG L04 if NR2 = 5 then TOG L05 if NR2 = 6 then TOG L06 if NR2 = 7 then TOG L07 if NR2 = 8 then TOG L08 if NR2 = 9 then TOG L09 if NR2 = 10 then TOG L10 if NR2 = 11 then TOG L11 if NR2 = 12 then TOG L12 if NR2 = 13 then TOG L13 if NR2 = 14 then TOG L14 if NR2 = 15 then TOG L15 if NR2 = 16 then TOG L16 if NR2 < 17 then goto reset PCFadresse = 64 'Adresse PCF8574 mit a0-A2 sys &h0126 'PCF8574 Lesen, Ergebnis in PCFDaten if NR2 = 17 AND (PCFDaten AND &B00000001) > 0 then PCFDaten = PCFDaten AND &B11111110 ELSE if NR2 = 17 AND (PCFDaten AND &B00000001) = 0 then PCFDaten = PCFDaten OR &B00000001 if NR2 = 18 AND (PCFDaten AND &B00000010) > 0 then PCFDaten = PCFDaten AND &B11111101 ELSE if NR2 = 18 AND (PCFDaten AND &B00000010) = 0 then PCFDaten = PCFDaten OR &B00000010 if NR2 = 19 AND (PCFDaten AND &B00000100) > 0 then PCFDaten = PCFDaten AND &B11111011 ELSE if NR2 = 19 AND (PCFDaten AND &B00000100) = 0 then PCFDaten = PCFDaten OR &B00000100 if NR2 = 20 AND (PCFDaten AND &B00001000) > 0 then PCFDaten = PCFDaten AND &B11110111 ELSE if NR2 = 20 AND (PCFDaten AND &B00001000) = 0 then PCFDaten = PCFDaten OR &B00001000 if NR2 = 21 AND (PCFDaten AND &B00010000) > 0 then PCFDaten = PCFDaten AND &B11101111 ELSE if NR2 = 21 AND (PCFDaten AND &B00010000) = 0 then PCFDaten = PCFDaten OR &B00010000 if NR2 = 22 AND (PCFDaten AND &B00100000) > 0 then PCFDaten = PCFDaten AND &B11011111 ELSE if NR2 = 22 AND (PCFDaten AND &B00100000) = 0 then PCFDaten = PCFDaten OR &B00100000 if NR2 = 23 AND (PCFDaten AND &B01000000) > 0 then PCFDaten = PCFDaten AND &B10111111 ELSE if NR2 = 23 AND (PCFDaten AND &B01000000) = 0 then PCFDaten = PCFDaten OR &B01000000 if NR2 = 24 AND (PCFDaten AND &B10000000) > 0 then PCFDaten = PCFDaten AND &B01111111 ELSE if NR2 = 24 AND (PCFDaten AND &B10000000) = 0 then PCFDaten = PCFDaten OR &B10000000 sys &h0101 'PCF8574 mit Daten = PCFDaten schreiben if NR2 > 24 and NR2 < 99 then goto error 'if NR2 = 99 then goto P99 goto reset #menu1 'abfragen ob speichern oder Laden (* | #) GOSUB Eingabe if NR = 11 then goto menu2 if NR = 12 then goto menu3 goto error #menu2 GOSUB Eingabe if NR2 = 0 and NR = 0 then goto error '0 --> error if NR2 > 9 and NR < 10 then goto error 'Nur zweistellige Zahlen zulassen if NR = 11 then goto error ' * -> error if NR2 <> 0 And NR2 <= 10 And NR = 12 then goto Laden 'Laden zwischen Speicherplatz 1 und 10 if NR2 = 0 And NR = 12 then goto error 'Enter ohne Eingabe -> Error if NR2 = 0 then goto Ziffer1 'Zwischenspeicher leer -> erste Stelle zwischenspeichern NR2 = NR + NR2 * 10 'zweite Stelle Berechnen goto menu2 #menu3 GOSUB Eingabe if NR2 = 0 and NR = 0 then goto error '0 --> error if NR2 > 9 and NR < 10 then goto error 'Nur zweistellige Zahlen zulassen if NR = 11 then goto error ' * -> error if NR2 <> 0 And NR2 <= 10 And NR = 12 then goto Speichern 'Speicherplatz zwischen 1 und 10 if NR2 = 0 And NR = 12 then goto error 'Enter ohne Eingabe -> Error if NR2 = 0 then goto Ziffer1 'Zwischenspeicher leer -> erste Stelle zwischenspeichern NR2 = NR + NR2 * 10 'zweite Stelle Berechnen goto menu3 #Input OPEN# FOR READ if EOF then goto error INPUT# Preset01 INPUT# Preset11 INPUT# Preset21 INPUT# Preset31 INPUT# Preset41 INPUT# Preset51 INPUT# Preset61 INPUT# Preset71 INPUT# Preset81 INPUT# Preset91 INPUT# Preset02 INPUT# Preset12 INPUT# Preset22 INPUT# Preset32 INPUT# Preset42 INPUT# Preset52 INPUT# Preset62 INPUT# Preset72 INPUT# Preset82 INPUT# Preset92 CLOSE# RETURN #Laden gosub Input if NR2 = 1 then Ports1 = Preset01 if NR2 = 1 then PCFDaten = Preset02 if NR2 = 2 then Ports1 = Preset11 if NR2 = 2 then PCFDaten = Preset12 if NR2 = 3 then Ports1 = Preset21 if NR2 = 3 then PCFDaten = Preset22 if NR2 = 4 then Ports1 = Preset31 if NR2 = 4 then PCFDaten = Preset32 if NR2 = 5 then Ports1 = Preset41 if NR2 = 5 then PCFDaten = Preset42 if NR2 = 6 then Ports1 = Preset51 if NR2 = 6 then PCFDaten = Preset52 if NR2 = 7 then Ports1 = Preset61 if NR2 = 7 then PCFDaten = Preset62 if NR2 = 8 then Ports1 = Preset71 if NR2 = 8 then PCFDaten = Preset72 if NR2 = 9 then Ports1 = Preset81 if NR2 = 9 then PCFDaten = Preset82 if NR2 = 10 then Ports1 = Preset91 if NR2 = 10 then PCFDaten = Preset92 PCFadresse = 64 'Adresse PCF8574 mit a0-A2 sys &h0101 'PCF8574 mit Daten = PCFDaten schreiben goto reset #speichern 'wirklich speichern? gosub Input PCFadresse = 64 'Adresse PCF8574 mit a0-A2 sys &h0126 'PCF8574 Lesen, Ergebnis in PCFDaten if NR2 = 1 then Preset01 = Ports1 if NR2 = 1 then Preset02 = PCFDaten if NR2 = 2 then Preset11 = Ports1 if NR2 = 2 then Preset12 = PCFDaten if NR2 = 3 then Preset21 = Ports1 if NR2 = 3 then Preset22 = PCFDaten if NR2 = 4 then Preset31 = Ports1 if NR2 = 4 then Preset32 = PCFDaten if NR2 = 5 then Preset41 = Ports1 if NR2 = 5 then Preset42 = PCFDaten if NR2 = 6 then Preset51 = Ports1 if NR2 = 6 then Preset52 = PCFDaten if NR2 = 7 then Preset61 = Ports1 if NR2 = 7 then Preset62 = PCFDaten if NR2 = 8 then Preset71 = Ports1 if NR2 = 8 then Preset72 = PCFDaten if NR2 = 9 then Preset81 = Ports1 if NR2 = 9 then Preset82 = PCFDaten if NR2 = 10 then Preset91 = Ports1 if NR2 = 10 then Preset92 = PCFDaten OPEN# FOR WRITE if FILEFREE < 20 then goto error PRINT# Preset01 PRINT# Preset11 PRINT# Preset21 PRINT# Preset31 PRINT# Preset41 PRINT# Preset51 PRINT# Preset61 PRINT# Preset71 PRINT# Preset81 PRINT# Preset91 PRINT# Preset02 PRINT# Preset12 PRINT# Preset22 PRINT# Preset32 PRINT# Preset42 PRINT# Preset52 PRINT# Preset62 PRINT# Preset72 PRINT# Preset82 PRINT# Preset92 CLOSE# goto reset #Eingabe wait key2 > 10 key = key2 pause 20 if key >=0 and key <=70 then NR=0 ' 0 if key >=111 and key <=111 then NR=1 ' 1 if key >=111 and key <=111 then NR=2 ' 2 if key >=89 and key <=94 then NR=3 ' 3 if key >=95 and key <=109 then NR=4 ' 4 if key >=110 and key <=128 then NR=5 ' 5 if key >=129 and key <=149 then NR=6 ' 6 if key >=150 and key <=172 then NR=7 ' 7 if key >=273 and key <=193 then NR=8 ' 8 if key >=194 and key <=219 then NR=9 ' 9 if key >=220 and key <=244 then NR=11 ' * if key >=245 and key <=255 then NR=12 ' # RETURN END syscode "I2C_M.obj"
das ist der Befehl für um Port 17 umzuschalten:
if NR2 = 17 AND (PCFDaten AND &B00000001) > 0 then PCFDaten = PCFDaten AND &B11111110 ELSE if NR2 = 17 AND (PCFDaten AND &B00000001) = 0 then PCFDaten = PCFDaten OR &B00000001








Zitieren

Lesezeichen