Author Topic: Arduino's I/O Expander Shield from cutedigi.com  (Read 2377 times)

0 Members and 1 Guest are viewing this topic.

Offline carloszoom3000Topic starter

  • Newbie
  • Posts: 6
  • Country: co
Arduino's I/O Expander Shield from cutedigi.com
« on: October 04, 2016, 04:16:13 pm »
Hi.

I'm using the I/O Expander shield from cutedigi.com (http://store.cutedigi.com/i-o-expander-shield-for-arduino-pcduino/).
It shows additional pins on the digital side of the Arduino.
If no code is uploaded to the Arduino, the pins DA7 and DA6 can be turned ON and OFF by the DIP 4 and 3 switches.
The pin DA5 is always high.
The rest of the pins are low.
When trying to program it, enabling the additional pins, using the DB# and DA# pins, it shows that the variable was not declared.

Ex:
void setup() {
pinMode(B2, OUTPUT);
}
void loop() {
digitalWrite(B2, HIGH);
}

When using the DA7 to DA0 pins, it allows you to compile and upload the code, however the pins are not enabled as expected.

Any help will be appreciated.

Regards.
 

Offline NandGate

  • Newbie
  • Posts: 6
  • Country: us
Re: Arduino's I/O Expander Shield from cutedigi.com
« Reply #1 on: October 04, 2016, 05:12:57 pm »
The tutorial for that board includes a code example.  Did you check that out?  http://learn.linksprite.com/arduino/shields/io-expander-shield-for-arduino/
 
The following users thanked this post: carloszoom3000

Offline carloszoom3000Topic starter

  • Newbie
  • Posts: 6
  • Country: co
Re: Arduino's I/O Expander Shield from cutedigi.com
« Reply #2 on: October 04, 2016, 07:02:35 pm »
Thanks for answering.
I uploaded the code shown there.
And i see they declare some pins as inputs.
They get 2 High levels and one low.

I though it was as easy as with the Arduino itself, so you just do
pinMode(13, OUTPUT);//declare digital pin as output

and then
digital Write(13, HIGH); set the digtal pin to 5V.

I know it might look like very well explained in the link you shared, but If there is any other example it would make things more clear.

Thanks in advance.

Regards,
 

Offline NandGate

  • Newbie
  • Posts: 6
  • Country: us
Re: Arduino's I/O Expander Shield from cutedigi.com
« Reply #3 on: October 04, 2016, 10:09:56 pm »
The extra pins on that shield are only accessible over I2C.  So you won't be able to use pinMode or digitalWrite. 

Code: [Select]
Wire.beginTransmission(mcp_address);
Wire.write((byte)IODIRA); // IODIRA register
Wire.write((byte)0x03); // set GPIOA-0/GPIOA-1 to inputs
Wire.endTransmission();

That changes the directions of the A pins.  0x03 represents a bitfield of all the pins, where a bit of 1 means that pin will be input, and a bit of 0 will be output.


Code: [Select]
Wire.write(GPIOA);    // address bank A
Wire.write((byte)0x04);  // value to send GPIOA-2 HIGH
Wire.endTransmission();

That sets the output states for all the A pins.  Again, just a bitfield, so you're setting the output state (HIGH or LOW) for all the pins at once.
 

Online KL27x

  • Super Contributor
  • ***
  • Posts: 4103
  • Country: us
Re: Arduino's I/O Expander Shield from cutedigi.com
« Reply #4 on: October 04, 2016, 10:21:35 pm »
I don't know Arduino, but if that is true it sounds like a halfbaked product.

First thing I did when needing to expand I/O with I2C is to write port emulator code. Reading/writing to I2C port expander is identical to any other port, other than the up to 10ms latency. Essentially all of my preexisting code will work on these new virtual ports, which have their own tristate, latch, and read registers which function exactly like a normal port.

The physical shield part? Ha. For what it really is I'm sure it will be fine. An introduction to I2C with some starting sample code.
« Last Edit: October 04, 2016, 10:28:40 pm by KL27x »
 

Offline NandGate

  • Newbie
  • Posts: 6
  • Country: us
Re: Arduino's I/O Expander Shield from cutedigi.com
« Reply #5 on: October 04, 2016, 10:33:19 pm »
Ahh, looks like good ole Adafruit provides a library that emulates more normal Arduino code:  https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library
And it looks like that library will work as-is with the default configuration on that board.

Example code is included in Adafruit's repo, for example:  https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library/blob/master/examples/toggle/toggle.ino
 

Online KL27x

  • Super Contributor
  • ***
  • Posts: 4103
  • Country: us
Re: Arduino's I/O Expander Shield from cutedigi.com
« Reply #6 on: October 04, 2016, 10:44:57 pm »
Clearly I'm in the wrong business.
Spend 1 or 2 days designing an Arduino Shield.
Let someone else write the software.
Profit.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf