-
Notifications
You must be signed in to change notification settings - Fork 8
/
PCA9536_Info.ino
106 lines (86 loc) · 4.21 KB
/
PCA9536_Info.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
PCA9536 LIBRARY - DEVICE INFORMATION STRING EXAMPLE
---------------------------------------------------
INTRODUCTION
------------
This sketch presents a minimal example of extending the PCA9536 Library to include an additional function for generating a printable device
information string which may be useful, for example, during debugging sessions.
As can be seen in the sketch below, implementation of this extended functionality only requires adding a single 'include' to the code, namely that of the relevant *.h file (PCA9536InfoStr.h).
Note that this functional extension does come at the cost of an increased memory usage, and therefore it seemed preferable to maintain it
as an optional add-on rather than include it in the core PCA9536 Library itself.
WIRING DIAGRAM
--------------
PCA9536
-------
IO0 --| • |-- VCC
| |
IO1 --| |-- SDA
| |
IO2 --| |-- SCL
| |
GND --| |-- IO3
-------
This hookup can be used with the following sketch:
PIN 1 (IO0) - Leave unconnected for the purpose of this sketch
PIN 2 (IO1) - Leave unconnected for the purpose of this sketch
PIN 3 (IO2) - Leave unconnected for the purpose of this sketch
PIN 4 (GND) - Connect to Arduino GND
PIN 5 (IO3) - Leave unconnected for the purpose of this sketch
PIN 6 (SCL) - Connect to Arduino Pin A5 with a 2K2 (400MHz) or 10K (100MHz) pull-up resistor
PIN 7 (SDA) - Connect to Arduino Pin A4 with a 2K2 (400MHz) or 10K (100MHz) pull-up resistor
PIN 8 (VCC) - Connect to Arduino 5V output
DECOUPING - Connect a 0.1uF Ceramic Capacitor between the PCA9536's VCC & GND pins
I2C ADDRESS
-----------
The PCA9536 has a single I2C address (factory hardwired):
PART DEVICE I2C ADDRESS PART
NUMBER (BIN) (HEX) (DEC) MARKING
-------- -------- ----- ----- -------
PCA9536D 01000001 0x41 65 PCA9536
Note: The 'D' suffix of the Part Number denotes the SOIC-8 package
BUG REPORTS
-----------
Please report any bugs/issues/suggestions in the Github Repository of this library at: https://github.com/nadavmatalon/PCA9536/issues
LICENSE
-------
The MIT License (MIT)
Copyright (c) 2016 Nadav Matalon
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without
limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "PCA9536.h"
#include "utility/PCA9536InfoStr.h"
PCA9536 pca9536;
void setup() {
Serial.begin(9600);
Wire.begin();
while(!Serial);
pca9536.reset();
Serial.print(F("\n\nPCA9536 DEVICE INFO STRING TESTING"));
Serial.print(F("\n----------------------------------\n"));
Serial.print(F("\nCURRENT SETTINGS:\n"));
Serial.print(PCA9536InfoStr(pca9536));
Serial.print(F("\nCHANGING TO NEW SETTINGS..."));
pca9536.setMode(IO0, IO_OUTPUT);
pca9536.setMode(IO2, IO_OUTPUT);
pca9536.setState(IO2, IO_LOW);
pca9536.setPolarity(IO1, IO_INVERTED);
Serial.print(F("DONE\n"));
Serial.print(PCA9536InfoStr(pca9536));
Serial.print(F("\nRESETTING DEVICE..."));
pca9536.reset();
Serial.print(F("DONE\n"));
Serial.print(PCA9536InfoStr(pca9536));
Serial.print(F("\n\n"));
}
void loop() {}