In Bascom hab ich was:
Code:
$regfile = "m32def.dat"
$crystal = 1000000
$baud = 9600
Declare Sub Schalte_relais(byval Relaisnr As Byte , Byval Status As Byte)
Dim I As Byte
Dim Relaisstatus As Byte
Const Relaisport_adr = &H76
'Ports für I2C-Bus
Config Scl = Portc.0
Config Sda = Portc.1
'I2C-Bus initialisieren
I2cinit
Config Porta = Output
Main:
For I = 0 To 7
Porta.i = 0
Call Schalte_relais(i , 1)
Wait 1
Porta.i = 1
Call Schalte_relais(i , 0)
Wait 1
Next I
Goto Main
Sub Schalte_relais(byval Relaisnr As Byte , Byval Status As Byte)
Relaisstatus.relaisnr = Status
I2cstart
I2cwbyte Relaisport_adr 'Schreibbefehl an PCF
I2cwbyte Relaisstatus 'Datenbyte an PCF
I2cstop
End Sub
Lesezeichen