Permalink
Browse files

Comments! Licenses!

Moved function explanation comments to the sx1509_library.h.

Slight changes to the digitalReadWrite example.
  • Loading branch information...
Jim Lindblom
Jim Lindblom committed Dec 13, 2012
1 parent 3e6afa1 commit 862dd3e9e3ce4825a64fce65ac8dd8aac6a5b1fd
@@ -68,30 +68,34 @@ const byte resetPin = 8;
// Or make an sx1509 object with just the SX1509 I2C address:
sx1509Class sx1509(SX1509_ADDRESS);
+// SX1509 pin defintions:
+const byte buttonPin = 1;
+const byte ledPin = 14;
+
void setup()
{
Serial.begin(9600);
sx1509.init(); // Initialize the SX1509, does Wire.begin()
- sx1509.pinDir(1, INPUT); // Set SX1509 pin 1 as an input
- sx1509.writePin(1, HIGH); // Activate pull-up
- sx1509.pinDir(14, OUTPUT); // Set SX1509 pin 14 as an output
+ sx1509.pinDir(buttonPin, INPUT); // Set SX1509 pin 1 as an input
+ sx1509.writePin(buttonPin, HIGH); // Activate pull-up
+ sx1509.pinDir(ledPin, OUTPUT); // Set SX1509 pin 14 as an output
// Blink pin 14 a few times
for (int i=0; i<5; i++)
{
- sx1509.writePin(14, LOW); // Write pin LOW
+ sx1509.writePin(ledPin, LOW); // Write pin LOW
delay(100);
- sx1509.writePin(14, HIGH); // Write pin HIGH
+ sx1509.writePin(ledPin, HIGH); // Write pin HIGH
delay(100);
}
}
void loop()
{
- int buttonValue = sx1509.readPin(1); // read pin 1 status
+ int buttonValue = sx1509.readPin(buttonPin); // read pin 1 status
if (buttonValue == 1) // by default pin 14 should be high
- sx1509.writePin(14, LOW); // turn pin off
+ sx1509.writePin(ledPin, LOW); // turn pin off
else
- sx1509.writePin(14, HIGH); // turn pin on
-}
+ sx1509.writePin(ledPin, HIGH); // turn pin on
+}
@@ -1,7 +1,14 @@
-/* SX1509_registers.h
+/*
+ sx1509_registers.h
+ Register definitions for SX1509.
+
by: Jim Lindblom
- SparkFun Electronics
- November 13, 2012
+ SparkFun Electronics
+ date: December 13, 2012
+
+ license: Beerware. Feel free to use it, with or without attribution, in
+ your own projects. If you find it helpful, buy me a beer next time you
+ see me at the local pub.
*/
#define REG_INPUT_DISABLE_B 0x00 // RegInputDisableB Input buffer disable register _ I/O[15_8] (Bank B) 0000 0000
Oops, something went wrong.

0 comments on commit 862dd3e

Please sign in to comment.