-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add CMakeLists.txt #8 - add debug function **uint8_t getPinMode8()** - add keywords.txt - update examples
- Loading branch information
1 parent
ebfe3b2
commit 5f763ae
Showing
9 changed files
with
209 additions
and
16 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
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,99 @@ | ||
// | ||
// FILE: MCP23008_test.ino | ||
// AUTHOR: Rob Tillaart | ||
// DATE: 2023-06-20 | ||
// PUPROSE: test MCP23008 library | ||
|
||
|
||
#include "MCP23008.h" | ||
#include "Wire.h" | ||
|
||
MCP23008 MCP(0x22); | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
Serial.print("MCP23008_test version: "); | ||
Serial.println(MCP23008_LIB_VERSION); | ||
|
||
Wire.begin(); | ||
MCP.begin(); | ||
|
||
test_pin_mode(); | ||
test_digital_read(); | ||
} | ||
|
||
|
||
void test_pin_mode() | ||
{ | ||
MCP.pinMode8(0x00); // 0 = output , 1 = input | ||
uint8_t value = MCP.getPinMode8(); | ||
Serial.println(value, HEX); | ||
|
||
MCP.pinMode8(0xFF); | ||
value = MCP.getPinMode8(); | ||
Serial.println(value, HEX); | ||
|
||
Serial.println(); | ||
for (int i = 0; i < 8; i++) | ||
{ | ||
MCP.pinMode(i, OUTPUT); | ||
value = MCP.getPinMode8(); | ||
Serial.println(value, HEX); | ||
} | ||
|
||
Serial.println(); | ||
for (int i = 0; i < 8; i++) | ||
{ | ||
MCP.pinMode(i, INPUT); | ||
value = MCP.getPinMode8(); | ||
Serial.println(value, HEX); | ||
} | ||
|
||
Serial.println(); | ||
for (int i = 0; i < 8; i++) | ||
{ | ||
MCP.pinMode(i, OUTPUT); | ||
value = MCP.getPinMode8(); | ||
Serial.println(value, HEX); | ||
} | ||
|
||
Serial.println(); | ||
for (int i = 0; i < 8; i++) | ||
{ | ||
MCP.pinMode(i, INPUT_PULLUP); | ||
value = MCP.getPinMode8(); | ||
Serial.println(value, HEX); | ||
} | ||
|
||
Serial.println(); | ||
} | ||
|
||
|
||
void test_digital_read() | ||
{ | ||
// set all lines to input | ||
MCP.pinMode8(0xFF); | ||
uint8_t value = MCP.getPinMode8(); | ||
Serial.println(value, HEX); | ||
|
||
uint32_t start = millis(); | ||
while (millis() - start < 60000) | ||
{ | ||
for (int i = 0; i < 8; i++) | ||
{ | ||
value = MCP.digitalRead(i); | ||
Serial.print(value, HEX); | ||
} | ||
Serial.println(); | ||
delay(1000); | ||
} | ||
} | ||
|
||
|
||
void loop() | ||
{ | ||
} | ||
|
||
|
||
// -- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Syntax Colouring Map For MCP23008 | ||
|
||
# Data types (KEYWORD1) | ||
MCP23008 KEYWORD1 | ||
|
||
|
||
# Methods and Functions (KEYWORD2) | ||
begin KEYWORD2 | ||
isConnected KEYWORD2 | ||
|
||
pinMode KEYWORD2 | ||
digitalWrite KEYWORD2 | ||
digitalRead KEYWORD2 | ||
|
||
setPolarity KEYWORD2 | ||
getPolarity KEYWORD2 | ||
setPullup KEYWORD2 | ||
getPullup KEYWORD2 | ||
|
||
pinMode8 KEYWORD2 | ||
write8 KEYWORD2 | ||
read8 KEYWORD2 | ||
|
||
setPolarity8 KEYWORD2 | ||
getPolarity8 KEYWORD2 | ||
setPullup8 KEYWORD2 | ||
getPullup8 KEYWORD2 | ||
|
||
lastError KEYWORD2 | ||
|
||
getPinMode8 KEYWORD2 | ||
|
||
|
||
# Instances (KEYWORD2) | ||
|
||
|
||
# Constants (LITERAL1) | ||
MCP23008_LIB_VERSION LITERAL1 | ||
|
||
MCP23008_OK LITERAL1 | ||
MCP23008_PIN_ERROR LITERAL1 | ||
MCP23008_I2C_ERROR LITERAL1 | ||
MCP23008_VALUE_ERROR LITERAL1 | ||
MCP23008_PORT_ERROR LITERAL1 |
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