Das Open-Control-Projekt - Die Alternative zur C-Control-I


Das Forum zur C-Control-1
Welche C-Control-Varianten existieren?
Übersicht - Suchen - Neueste 50 Beiträge - Neuer Beitrag - Login - Registrieren
INFO - FAQ - CC2-Forum - CCPro-Forum 

 IR Abfrage Kategorie: Programmierung Basic (von Manfred - 14.11.2006 20:35)
Manfred nutzt:  CC1-Unit V1.1
Hallo Leute,

nach 3 jähriger Abstinenz habe ich mich mal wieder an meine alte C Control gewagt und verloren.
Eigentlich wollte ich folgendes Projekt realisieren, aber spukt mir das IR Modul in die Suppe und bringt ganz verrückte Werte (ADDRESS und Command).

Kann mir jemand von Euch das erklären....

Ich hab schon rauf und runter gesucht ....

Wo liegt den mein Denkfehler??

Herzlichen Dank für Eure Antwort

LG

Manfred


'Lichtsteuerung mit der C Control 1, einem IR Modul, und
'derzeit einem PCF Adresse 78 auf den PIN´s 7 und 8

define T_Alle Byteport[2] 'Alle Taster in einem Byte
define taster1 port[9]
define taster2 port[10]
define taster3 port[11]
define taster4 port[12]
define taster5 port[13]
define taster6 port[14]
define taster7 port[15]
define taster8 port[16]
define SDA     port[7]                 'gn
define SCL     port[8]                 'br
'IR            port 1 und 2

define R_Alle byte [1] ' Status aller 8 Lampen
define lampe1 bit[1]
define lampe2 bit[2]
define lampe3 bit[3]
define lampe4 bit[4]
define lampe5 bit[5]
define esstisch1 bit[6]
define esstisch2 bit[7]
define couchtisch bit[8]

define COMMAND          word[3]
define ADDRESS          byte[5]
define SUBCMD           byte[7]
define PCFDaten         byte[8]
define N                byte[9]

'Programmstart

#set_RC5
SUBCMD=3
sys&H101
pause 50
R_Alle = 255

#Hauptprogramm
SUBCMD=1
sys&H101               'address und Command von IR Empfänger Modul holen
if COMMAND <> 0 then gosub IrSchalter
gosub tastenabfrage
SDA = ON
SCL = ON
    gosub I2C_start
    pcfdaten = 78      'Adresse PCF8574
    gosub I2C_schreiben
    pcfdaten = R_Alle
    gosub I2C_schreiben
    gosub I2C_stop
goto Hauptprogramm           'Endlosschleife




#I2C_start
  SDA = OFF
  SCL = OFF
  return

#I2C_stop
  SDA = OFF
  SCL = ON
  SDA = ON
  return

#I2C_schreiben
  for N = 1 to 8
    SDA= OFF
    if (pcfdaten AND 128) = 128 then SDA = ON
    pulse SCL
    pcfdaten = pcfdaten shl 1 '1 Bit nach links
  next
  pulse SCL             ' 9. Impuls
  return


#getirdata
SUBCMD=1
sys&H101
return

#IrSchalter
If ADDRESS=20 and COMMAND =01 then lampe1=not lampe1 'Schaltet den Status um
If ADDRESS=20 and COMMAND =02 then lampe2=not lampe2
If ADDRESS=20 and COMMAND =03 then lampe3=not lampe3
If ADDRESS=20 and COMMAND =04 then lampe4=not lampe4
If ADDRESS=20 and COMMAND =05 then lampe5=not lampe5
If ADDRESS=20 and COMMAND =06 then esstisch1=not esstisch1
If ADDRESS=20 and COMMAND =07 then esstisch2=not esstisch2
If ADDRESS=20 and COMMAND =08 then couchtisch=not couchtisch
return

#tastenabfrage
If Taster1=off then lampe1=not lampe1 'Schaltet den Status um
If Taster2=off then lampe2=not lampe2
If Taster3=off then lampe3=not lampe3
If Taster4=off then lampe4=not lampe4
If Taster5=off then lampe5=not lampe5
If Taster6=off then esstisch1=not esstisch1
If Taster7=off then esstisch2=not esstisch2
If Taster8=off then couchtisch=not couchtisch
pause 3                            ' Taster entprellen - Wert evtl. anpassen
wait T_Alle=255                      'warten bis alle Taster losgelassen
if T_Alle<255 then goto Tastenabfrage 'eine Taste gedrückt
return

end
syscode "irdriv.s19"

 Antwort schreiben

Bisherige Antworten: