-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update readme.md (interrupts) + examples
- Loading branch information
1 parent
98ffc54
commit 1e1ef39
Showing
17 changed files
with
193 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
examples/PCF8575_interrupt_advanced/PCF8575_interrupt_advanced.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// | ||
// FILE: PCF8575_interrupt_advanced.ino | ||
// AUTHOR: Rob Tillaart | ||
// DATE: 2021-01-03 | ||
// PURPOSE: test PCF8575 library | ||
// URL: https://github.com/RobTillaart/PCF8575 | ||
// | ||
// TEST SETUP | ||
// Connect INT pin of the PCF8575 to UNO pin 2 | ||
// | ||
// (from figure 4 datasheet | ||
// Place a pull up resistor 4K7 between pin and 5V | ||
// Place a capacitor 10-400 pF between pin and GND | ||
|
||
|
||
#include "PCF8575.h" | ||
|
||
PCF8575 PCF(0x20); | ||
|
||
|
||
//////////////////////////////////// | ||
// | ||
// INTERRUPT ROUTINE + FLAG | ||
// | ||
const int IRQPIN = 2; | ||
|
||
volatile bool flag = false; | ||
|
||
void pcf_irq() | ||
{ | ||
flag = true; | ||
} | ||
|
||
|
||
//////////////////////////////////// | ||
// | ||
// MAIN CODE | ||
// | ||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
Serial.println(__FILE__); | ||
Serial.print("PCF8575_LIB_VERSION:\t"); | ||
Serial.println(PCF8575_LIB_VERSION); | ||
|
||
Wire.begin(); | ||
|
||
PCF.begin(); | ||
|
||
pinMode(IRQPIN, INPUT_PULLUP); | ||
attachInterrupt(digitalPinToInterrupt(IRQPIN), pcf_irq, FALLING); | ||
} | ||
|
||
|
||
void loop() | ||
{ | ||
uint32_t now = millis(); | ||
if (flag) | ||
{ | ||
flag = false; | ||
uint16_t x = PCF.read16(); | ||
Serial.print("READ:\t"); | ||
Serial.print('\t'); | ||
Serial.print(now); | ||
Serial.print('\t'); | ||
Serial.println(x, HEX); | ||
} | ||
// do other things here | ||
delay(10); | ||
} | ||
|
||
|
||
// -- END OF FILE -- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.