MCP23S17 not working at all

Hello,

I'm trying to use the MCP23S17 with my Arduino Uno board. I wired everything like this :


I wired a switch with pull-down 10K resistor on the GPB0 pin (Physically PIN 1 of the IC) which according to the document above is the input # 9.

I programmed a simple sketch for testing :

#include <SPI.h>
#include <MCP23S17.h>

MCP onechip(0);

int onevalue = 0;

void setup()
{
Serial.begin(9600);
}

void loop()
{
onevalue = onechip.digitalRead(9);
if (onevalue = 1)
{
Serial.println ("ON");
}
else
{
Serial.printl ("OFF");
}
}

My problem is that the serial only shows "ON" from the begining disregarding the switch position. I can put out all the wires linking my Arduino to the breadboard nothing changes, always "ON" on the debug window. I tried to put pull-down resistors on available inputs, nothing changes, I checked my circuit many times, everything is like the document from Arduino Playground. I don't understand anything, could somebody help me please ?

if (onevalue = 1)

should be

if (onevalue == 1)

one = is an assignement
two == is a comparison

Please use CTRL-T before copying the code to autoformat
and use code tags -> # button above smileys

I'm so stupid !!!

Thank you very much, I try now and come back

Sometimes you check things so close that you cannot see anything, even such basic things. I changed = to == and everything works fine now. Thank you very very much !

welcome, next time you can help someone out :wink:

Is there anyone who hasn't done that at least once (intentionally or unintentionally) ?
I know about it but still find myself dropping a "=" once in a while if I am coding in a hurry.