Skip to content

Commit 862dd3e

Browse files
author
Jim Lindblom
committed
Comments! Licenses!
Moved function explanation comments to the sx1509_library.h. Slight changes to the digitalReadWrite example.
1 parent 3e6afa1 commit 862dd3e

File tree

4 files changed

+434
-270
lines changed

4 files changed

+434
-270
lines changed

Arduino/libraries/SX1509/examples/sx1509_digitalReadWrite/sx1509_digitalReadWrite.ino

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,30 +68,34 @@ const byte resetPin = 8;
6868
// Or make an sx1509 object with just the SX1509 I2C address:
6969
sx1509Class sx1509(SX1509_ADDRESS);
7070

71+
// SX1509 pin defintions:
72+
const byte buttonPin = 1;
73+
const byte ledPin = 14;
74+
7175
void setup()
7276
{
7377
Serial.begin(9600);
7478
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
7882

7983
// Blink pin 14 a few times
8084
for (int i=0; i<5; i++)
8185
{
82-
sx1509.writePin(14, LOW); // Write pin LOW
86+
sx1509.writePin(ledPin, LOW); // Write pin LOW
8387
delay(100);
84-
sx1509.writePin(14, HIGH); // Write pin HIGH
88+
sx1509.writePin(ledPin, HIGH); // Write pin HIGH
8589
delay(100);
8690
}
8791
}
8892

8993
void loop()
9094
{
91-
int buttonValue = sx1509.readPin(1); // read pin 1 status
95+
int buttonValue = sx1509.readPin(buttonPin); // read pin 1 status
9296

9397
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
9599
else
96-
sx1509.writePin(14, HIGH); // turn pin on
97-
}
100+
sx1509.writePin(ledPin, HIGH); // turn pin on
101+
}

Arduino/libraries/SX1509/sx1509_includes/sx1509_registers.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
/* SX1509_registers.h
1+
/*
2+
sx1509_registers.h
3+
Register definitions for SX1509.
4+
25
by: Jim Lindblom
3-
SparkFun Electronics
4-
November 13, 2012
6+
SparkFun Electronics
7+
date: December 13, 2012
8+
9+
license: Beerware. Feel free to use it, with or without attribution, in
10+
your own projects. If you find it helpful, buy me a beer next time you
11+
see me at the local pub.
512
*/
613

714
#define REG_INPUT_DISABLE_B 0x00 // RegInputDisableB Input buffer disable register _ I/O[15_8] (Bank B) 0000 0000

0 commit comments

Comments
 (0)