Hallo David,
evtl. hilft Dir ja das folgende kleine Progr.
Mega8 + PCF8574 + 8 LED's an dessen Port's.
Code:
$regfile = "m8def.dat" 'ATmega8-Deklarationen
$crystal = 3686400 'Quarz: 3,6864 MHz
$baud = 9600 'Baudrate zum PC: 9600 Baud
'
Config Sda = Portc.4 'ist für I2C erforderlich
Config Scl = Portc.5 'dito
'...............................................................................
Const Pcfled = &H40 'Adresses PCF8574 0.0.0
'BITMUSTER LED
Const Led_0 = &B00000001 'PCF Port 0 ein
Const Led_1 = &B00000010 'PCF Port 1 ein
Const Led_2 = &B00000100 'PCF Port 2
Const Led_3 = &B00001000 'PCF Port 3
Const Led_4 = &B00010000 'PCF Port 4
Const Led_5 = &B00100000 'PCF Port 5
Const Led_6 = &B01000000 'PCF Port 6
Const Led_7 = &B10000000 'PCF Port 7
Const Led_blank = &B00000000 'alle LED aus
' --- Programmoperationen ------------------------------------------------------
I2cinit 'I2C Bus initialisieren
Do
I2cstart 'Bus starten
I2cwbyte Pcfled 'Addresse PCF senden
I2cwbyte Led_0 'LED-Bitmuster senden
Wait 2
I2cwbyte Led_1 'LED-Bitmuster senden
Wait 2
I2cwbyte Led_2 'LED-Bitmuster senden
Wait 2
I2cwbyte Led_3 'LED-Bitmuster senden
Wait 2
I2cwbyte Led_4 'LED-Bitmuster senden
Wait 2
I2cwbyte Led_5 'LED-Bitmuster senden
Wait 2
I2cwbyte Led_6 'LED-Bitmuster senden
Wait 2
I2cwbyte Led_7 'LED-Bitmuster senden
Wait 2
I2cwbyte Led_blank 'LED-Bitmuster senden
Wait 2
I2cstop 'Bus wieder freigeben
Loop
End 'end program
mfg Gerhard
Lesezeichen