MCP23s17 with the ESP8266
Posted: Fri Jan 06, 2017 10:16 am
Hi guy
Im looking for an explanation in something that has me stumped.
I currently have a MCP23S17 hooked up to the the ESP8266. I use the following library to access the the expander chip: https://github.com/n0mjs710/MCP23S17
So, I hooked up a button with a few LED's and all works well, except that when the button is high (pushed), I get a reading of 3855 and when its set to low, I get a reading 2831.
3855 - 2831 = 1024 , which works out 2^10.
What I don't understand ... where does the 3855, 2831 values come from?
Im looking for an explanation in something that has me stumped.
I currently have a MCP23S17 hooked up to the the ESP8266. I use the following library to access the the expander chip: https://github.com/n0mjs710/MCP23S17
So, I hooked up a button with a few LED's and all works well, except that when the button is high (pushed), I get a reading of 3855 and when its set to low, I get a reading 2831.
3855 - 2831 = 1024 , which works out 2^10.
What I don't understand ... where does the 3855, 2831 values come from?
Code: Select all
#include <SPI.h>
#include "Mcp23s17.h"
#define MCP23S17_SLAVE_SELECT_PIN 15
MCP23S17 Mcp23s17 = MCP23S17( MCP23S17_SLAVE_SELECT_PIN );
void setup()
{
Serial.begin(115200);
Mcp23s17.pinMode(OUTPUT);
Mcp23s17.port(0x0F0F);
Mcp23s17.pinMode(8,OUTPUT);
Mcp23s17.pinMode(9,OUTPUT);
Mcp23s17.pinMode(10,INPUT);
Mcp23s17.digitalWrite(8, HIGH);
delay(100);
Mcp23s17.digitalWrite(9, HIGH);
}
void loop()
{
int vin = Mcp23s17.digitalRead(10);
Serial.print("Voltage - ");
Serial.println(vin);
delay(200);
}