Moin!
Weil ich am Ende meines Projektes vor dem Dilemma stand, zu wenige i/0 pins am Controller zu haben, kam ein PCF 8574 zum Einsatz.
Ich brauchte Pins für drei weitere Eingabetaster. Funktioniert auch soweit, allerdings müssen die Taster noch DRINGEND entprellt werden.
Weiß jemand, wie ich die Taster- Eingaben via 8574 softwaremäßig entprellen kann?
Folgender Code funktioniert, prellt aber furchtbar...
$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 100
$swstack = 100
$framesize = 100
Dim Inhalt As Byte
Ddrd = &B11111111
Ddrb = &B11111111
Ddrc = &B11111111
Config Twi = 400000
Config Scl = Portc.5
Config Sda = Portc.4
Config Debounce = 50
I2cinit
Const Pcf8574a = &B01110001
Led Alias Portd.6
Do
Gosub 8574
If Inhalt.5 = 0 Then
Toggle Led
End If
Loop
8574:
I2cstart
I2cwbyte Pcf8574a
I2crbyte Inhalt , Nack
I2cstop
Return
Weil ich am Ende meines Projektes vor dem Dilemma stand, zu wenige i/0 pins am Controller zu haben, kam ein PCF 8574 zum Einsatz.
Ich brauchte Pins für drei weitere Eingabetaster. Funktioniert auch soweit, allerdings müssen die Taster noch DRINGEND entprellt werden.
Weiß jemand, wie ich die Taster- Eingaben via 8574 softwaremäßig entprellen kann?
Folgender Code funktioniert, prellt aber furchtbar...
$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 100
$swstack = 100
$framesize = 100
Dim Inhalt As Byte
Ddrd = &B11111111
Ddrb = &B11111111
Ddrc = &B11111111
Config Twi = 400000
Config Scl = Portc.5
Config Sda = Portc.4
Config Debounce = 50
I2cinit
Const Pcf8574a = &B01110001
Led Alias Portd.6
Do
Gosub 8574
If Inhalt.5 = 0 Then
Toggle Led
End If
Loop
8574:
I2cstart
I2cwbyte Pcf8574a
I2crbyte Inhalt , Nack
I2cstop
Return