Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By Samighi11
#28874
johntech2014 wrote:
martinayotte wrote:
johntech2014 wrote:but I don't see any way to turn on multiple LED's at one time.


Code: Select allvoid Adafruit_MCP23017::writeGPIOAB(uint16_t ba) {


Ok I did see that somewhere in the AdaFruit library but have no clue what it means. I was also searching the AdaFruit site for information on that and how to use it, nothing concrete that I could figure out. I'll just keep looking.

Thanks



You need to send it a 16 bit integer. Each bit representing an output. 0 = all off. 1 = led 1 on, 2 = led 2 on, 3 would be both on. Simply used binary functions. 255*256+255 = would be all light.
User avatar
By johntech2014
#28884
Code: Select allvoid Adafruit_MCP23017::writeGPIOAB(uint16_t ba) {
[/quote]
You need to send it a 16 bit integer. Each bit representing an output. 0 = all off. 1 = led 1 on, 2 = led 2 on, 3 would be both on. Simply used binary functions. 255*256+255 = would be all light.[/quote]

After reading about what "uint16" meant I understand how it works. I did know how the binary counting worked, that is why I wanted to set it up that way.
I just didn't know what void Adafruit_MCP23017::writeGPIOAB meant or how to set it up. I was trying to find out more about this on the AdaFruit site but looking at the library for this is still confusing for me. I guess I'm still in the LED and sensor stage of my learning curve with Arduino sketches.

Thanks for the information you have provided!!

John
User avatar
By johntech2014
#29100
johntech2014 wrote:
martinayotte wrote:
johntech2014 wrote:but I don't see any way to turn on multiple LED's at one time.


Code: Select allvoid Adafruit_MCP23017::writeGPIOAB(uint16_t ba) {




Ok I 'm asking for help on this one again. I have searched and searched for a bit of code to make this work. I have even asked the people at AdaFruit for help and they stated the same thing. Just feed these numbers in and you will see how the outputs will change
Code: Select all0xff00
0x00ff
0xf00f
0xc003
0x8001


I am not sure where in the sketch it is supposed to go . I have tried in the beginning, middle and even near the end. Supposedly then you use the command .writeGPIOAB() with one of the numbers from the above list and it will turn on the outputs corresponding to the bits representation of the number. It's probably right in front of me and I'm not seeing it. Any suggestions or maybe a hint or two?

Thanks

John
User avatar
By Samighi11
#29106 @johntech2014 - Please post your sketch.

there is probably a begin function to the library that you need to execute, and then process these commands.

Here is how I have debugged the same exact issue
a) Load the i2c scanner sketch (default one) and ensure your device can see the I2C ports of the 20317.
b) ensure it sees them and you have the correct I2C address (see my code from before). I used the Wire library.
c) A0, A1, A2 on the MCP23017 determine the address
d) There is also a RESET that has to be high for the chip to accept commands.
e) lastly ensure your SDA and SCL are wired correctly. Note that on some ESP8266 models GPIO4 and 5 are reversed (I have found this to be true).

if you have A0, A1, A2, SDA, SCL and RESET set, and the chip is powered VCC - Source, VDD ground, the I2C scanner sketch should pick it up. That is where you would start. Until I2C scanner shows you the address, none of your sketches will work.