Skip to content

Unable to use MCP23017 with Adafruit MCP23017 LCD Hat #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SuperNinja-4965 opened this issue Apr 5, 2019 · 0 comments
Closed

Unable to use MCP23017 with Adafruit MCP23017 LCD Hat #27

SuperNinja-4965 opened this issue Apr 5, 2019 · 0 comments

Comments

@SuperNinja-4965
Copy link

My code is as follows:
`// Connect pin #12 of the expander to Analog 5 (i2c clock)
// Connect pin #13 of the expander to Analog 4 (i2c data)
// Connect pins #15, 16 and 17 of the expander to 3V3 (address selection)
// Connect pin #9 of the expander to 5V (power)
// Connect pin #10 of the expander to ground (common ground)
// Connect pin #18 through a ~10kohm resistor to 5V (reset pin, active low)

// Input #0 is on pin 21 so connect a button or switch from there to ground

// include the library code:
#include <Wire.h>
#include <Adafruit_RGBLCDShield.h>
#include <utility/Adafruit_MCP23017.h>
//#include "Adafruit_MCP23017.h"

// The shield uses the I2C SCL and SDA pins. On classic Arduinos
// this is Analog 4 and 5 so you can't use those for analogRead() anymore
// However, you can connect other I2C sensors to the I2C bus and share
// the I2C bus.
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
Adafruit_MCP23017 mcp;

// These #defines make it easy to set the backlight color
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7
#define addr1 7 // 7 = A1 high, A2 high, A3 high

void setup() {
// Debugging output
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
mcp.begin(addr1);
mcp.pinMode(0, INPUT);
mcp.pullUp(0, HIGH); // turn on a 100K pullup internally

pinMode(13, OUTPUT); // use the p13 LED as debugging

// Print a message to the LCD. We track how long it takes since
// this library has been optimized a bit and we're proud of it :)
int time = millis();
lcd.print("Hello, world!");
time = millis() - time;
Serial.print("Took "); Serial.print(time); Serial.println(" ms");
lcd.setBacklight(RED);
}

uint8_t i=0;
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);

uint8_t buttons = lcd.readButtons();

if (buttons) {
lcd.clear();
lcd.setCursor(0,0);
if (buttons & BUTTON_UP) {
lcd.print("UP ");
}
if (buttons & BUTTON_DOWN) {
lcd.print("DOWN ");
}
if (buttons & BUTTON_LEFT) {
lcd.print("LEFT ");
}
if (buttons & BUTTON_RIGHT) {
lcd.print("RIGHT ");
}
if (buttons & BUTTON_SELECT) {
lcd.print("SELECT ");
}
}
digitalWrite(13, mcp.digitalRead(0));
}`

for some reson the hat is working but the other MCP23017 chip

@SuperNinja-4965 SuperNinja-4965 changed the title Unable to use MCP23017 with Adafruit MCP23017 LCD HAt Unable to use MCP23017 with Adafruit MCP23017 LCD Hat Apr 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant