Arduino-TWI
Two-Wire Interface (TWI) library for Arduino
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
PCF8574.ino
Go to the documentation of this file.
1
#include "
TWI.h
"
2
#include "
Driver/PCF8574.h
"
3
4
// Configure: TWI bus manager
5
// #define USE_SOFTWARE_TWI
6
7
#if defined(USE_SOFTWARE_TWI)
8
#include "GPIO.h"
9
#include "
Software/TWI.h
"
10
Software::TWI<BOARD::D18, BOARD::D19>
twi
;
11
#else
12
// Configure: Hardware TWI bus clock frequency (100 or 400 kHz)
13
#define FREQ 100000UL
14
// #define FREQ 400000UL
15
#include "
Hardware/TWI.h
"
16
Hardware::TWI
twi
(
FREQ
);
17
#endif
18
19
PCF8574
port
(twi, 0);
20
PCF8574::GPIO<0>
pin
(
port
);
21
22
void
setup
()
23
{
24
Serial.begin(57600);
25
while
(!Serial);
26
27
pin
.output();
28
}
29
30
void
loop
()
31
{
32
static
bool
state =
false
;
33
34
pin
= state;
35
Serial.print(F(
"pin = "
));
36
Serial.println(
pin
);
37
38
Serial.print(F(
"port.read() = "
));
39
Serial.println(
port
.
read
(), BIN);
40
delay(10);
41
42
for
(
int
i = 0; i < 16; i++)
43
pin
= (state = !state);
44
delay(10);
45
46
uint8_t buf[] = { 0, 1, 0, 1, 0, 1, 0, 1 };
47
port
.
write
(buf,
sizeof
(buf));
48
delay(1000);
49
}
loop
void loop()
Definition:
PCF8574.ino:30
port
PCF8574 port(twi, 0)
Software::TWI
Definition:
TWI.h:32
Hardware::TWI
Definition:
TWI.h:28
PCF8574::write
void write(uint8_t value)
Definition:
PCF8574.h:108
TWI.h
PCF8574.h
FREQ
#define FREQ
Definition:
PCF8574.ino:13
TWI.h
setup
void setup()
Definition:
PCF8574.ino:22
PCF8574
Definition:
PCF8574.h:46
pin
PCF8574::GPIO< 0 > pin(port)
PCF8574::GPIO
Definition:
PCF8574.h:136
PCF8574::read
uint8_t read()
Definition:
PCF8574.h:86
twi
Hardware::TWI twi(FREQ)
examples
PCF8574
PCF8574.ino
Generated on Sat Oct 14 2017 03:13:18 for Arduino-TWI by
1.8.11