Output from MCP23017 working

This commit is contained in:
Brendan Haines 2017-01-24 23:05:59 -07:00
parent ae12993f55
commit ffb56e01da

View File

@ -12,40 +12,51 @@ MAX6675 t0(CLK0, CS0, MISO0);
Adafruit_MCP23017 mcp; Adafruit_MCP23017 mcp;
void setup() { void setup() {
Wire.pins(4,5); // LED
pinMode(2, OUTPUT);
// I2C
Wire.pins(4, 5);
// LCD // LCD
lcd.init(); lcd.init();
lcd.init(); lcd.init();
lcd.backlight(); lcd.backlight();
lcd.setCursor(0,0); lcd.setCursor(0, 0);
lcd.print("Initializing... "); lcd.print("Initializing... ");
// MCP23017 GPIO expander // MCP23017 GPIO expander
mcp.begin(); mcp.begin();
mcp.pinMode(0, OUTPUT); mcp.pinMode(0, OUTPUT);
mcp.digitalWrite(0, HIGH); mcp.digitalWrite(0, HIGH);
digitalWrite(2, LOW);
delay(100); delay(100);
mcp.digitalWrite(0, LOW); mcp.digitalWrite(0, LOW);
digitalWrite(2, HIGH);
// Clear LCD // Clear LCD
lcd.setCursor(0,0); lcd.setCursor(0, 0);
lcd.print(" "); lcd.clear();
} }
void loop() { void loop() {
// Get value // Get value
lcd.setCursor(0,0); lcd.setCursor(0, 0);
lcd.print(t0.readFahrenheit()); lcd.print(t0.readFahrenheit());
lcd.print("F ");
lcd.print(t0.readCelsius());
lcd.print("C");
// LED stuff // LED stuff
lcd.setCursor(0,1); lcd.setCursor(0, 1);
lcd.print("LED: ON "); lcd.print("LED: ON ");
mcp.digitalWrite(0, HIGH); mcp.digitalWrite(0, HIGH);
delay(1000); digitalWrite(2, LOW);
lcd.setCursor(0,1); delay(2000);
lcd.setCursor(0, 1);
lcd.print("LED: OFF"); lcd.print("LED: OFF");
mcp.digitalWrite(0, LOW); mcp.digitalWrite(0, LOW);
delay(1000); digitalWrite(2, HIGH);
delay(2000);
} }