@@ -68,30 +68,34 @@ const byte resetPin = 8;
68
68
// Or make an sx1509 object with just the SX1509 I2C address:
69
69
sx1509Class sx1509 (SX1509_ADDRESS);
70
70
71
+ // SX1509 pin defintions:
72
+ const byte buttonPin = 1 ;
73
+ const byte ledPin = 14 ;
74
+
71
75
void setup ()
72
76
{
73
77
Serial.begin (9600 );
74
78
sx1509.init (); // Initialize the SX1509, does Wire.begin()
75
- sx1509.pinDir (1 , INPUT); // Set SX1509 pin 1 as an input
76
- sx1509.writePin (1 , HIGH); // Activate pull-up
77
- sx1509.pinDir (14 , OUTPUT); // Set SX1509 pin 14 as an output
79
+ sx1509.pinDir (buttonPin , INPUT); // Set SX1509 pin 1 as an input
80
+ sx1509.writePin (buttonPin , HIGH); // Activate pull-up
81
+ sx1509.pinDir (ledPin , OUTPUT); // Set SX1509 pin 14 as an output
78
82
79
83
// Blink pin 14 a few times
80
84
for (int i=0 ; i<5 ; i++)
81
85
{
82
- sx1509.writePin (14 , LOW); // Write pin LOW
86
+ sx1509.writePin (ledPin , LOW); // Write pin LOW
83
87
delay (100 );
84
- sx1509.writePin (14 , HIGH); // Write pin HIGH
88
+ sx1509.writePin (ledPin , HIGH); // Write pin HIGH
85
89
delay (100 );
86
90
}
87
91
}
88
92
89
93
void loop ()
90
94
{
91
- int buttonValue = sx1509.readPin (1 ); // read pin 1 status
95
+ int buttonValue = sx1509.readPin (buttonPin ); // read pin 1 status
92
96
93
97
if (buttonValue == 1 ) // by default pin 14 should be high
94
- sx1509.writePin (14 , LOW); // turn pin off
98
+ sx1509.writePin (ledPin , LOW); // turn pin off
95
99
else
96
- sx1509.writePin (14 , HIGH); // turn pin on
97
- }
100
+ sx1509.writePin (ledPin , HIGH); // turn pin on
101
+ }
0 commit comments