blemasle / arduino-mcp23017

Complete support of MCP23017
MIT License
71 stars 40 forks source link

INPUT-OUTPUT-Definition #4

Closed Bms7 closed 5 years ago

Bms7 commented 5 years ago

In MCP23017.cpp line 41 setting of OUTPUT is: iodir = readRegister(iodirreg); if(mode == OUTPUT) iodir |= _BV(pin); else iodir &= ~_BV(pin);

but from datasheet: 3.5.1 I/O DIRECTION REGISTER Controls the direction of the data I/O. When a bit is set, the corresponding pin becomes an input. When a bit is clear, the corresponding pin becomes an output.

So please correct Thanks

blemasle commented 5 years ago

Hi @Bms7 . You're absolutely right. Sorry about that. I just pushed the fix. The updated library should be available under the version 1.1.1 on the Arduino Library Manager within a few hours.

Bms7 commented 5 years ago

Hi, in my version I simply changed "OUT" of "OUTPUT" to "IN" -> "INPUT". Was the easyiest way ;-) Yours

-----Original-Nachricht----- Betreff: Re: [blemasle/arduino-mcp23017] INPUT-OUTPUT-Definition (#4) Datum: 2019-02-19T16:28:54+0100 Von: "Bertrand Lemasle" notifications@github.com An: "blemasle/arduino-mcp23017" arduino-mcp23017@noreply.github.com

Hi @Bms7 https://github.com/Bms7 . You're absolutely right. Sorry about that. I just pushed the fix. The updated library should be available under the version 1.1.1 on the Arduino Library Manager within a few hours. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/blemasle/arduino-mcp23017/issues/4#issuecomment-465176812 , or mute the thread https://github.com/notifications/unsubscribe-auth/Atj6q4Qvm9u5EpDKQRwfDrD66WuOdRPtks5vPBgtgaJpZM4bCdbo . {"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/blemasle/arduino-mcp23017","title":"blemasle/arduino-mcp23017","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/blemasle/arduino-mcp23017"}},"updates":{"snippets":[{"icon":"PERSON","message":"@blemasle in #4: Hi @Bms7 . You're absolutely right. Sorry about that. I just pushed the fix. The updated library should be available under the version 1.1.1 on the Arduino Library Manager within a few hours."}],"action":{"name":"View Issue","url":"https://github.com/blemasle/arduino-mcp23017/issues/4#issuecomment-465176812"}}} [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/blemasle/arduino-mcp23017/issues/4#issuecomment-465176812", "url": "https://github.com/blemasle/arduino-mcp23017/issues/4#issuecomment-465176812", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ] 

blemasle commented 5 years ago

Yep, I struggled between the two solutions. Annnndd now I prefer the look of the other one (yours) 😄 Might change that on the next version...

pspastushkov commented 5 years ago

Hi! Problem with uint8_t MCP23017 :: digitalRead "if (mcp23017_0x21.digitalRead(2)) " gives truth only when pin 0 is high Changing "2" to another pin (1-15) does not give a result How to read the state of pin number n?

Thanks

blemasle commented 5 years ago

hi @pspastushkov. It should work. Could you try to directly read the register and ensure that the value is changing on your chip (use readRegister(MCP2017_REGISTER::GPIOA) or GPIOB ) ? If it is indeed not working, please open a new issue :)

pspastushkov commented 5 years ago

Sorry. Ok