There are easy ways of getting more I/O pins for any project; shift registers, I2C expanders, or ADCs will give you plenty of pins for whatever project you have in mind. All these require extra components, though. Enter the ExtraCore library for Arduino, a software library that turns two or more Arduinos into a multi-core microcontroller with more pins than you’ll ever need.
The ExtraCore library comes from [Dustin Andrews], and allows anyone to control the input and output pins of two Arduinos with the same ease as a single Arduino.
The hardware setup is fairly simple – just connect A4, A5, power, and ground on both Arduinos together. After installing the ‘client’ sketch on the second Arduino, you can modify the ‘manager’ sketch to suit whatever project you’re building. From there you’ve nearly doubled the number of Arduino pins your project can control.
It may not be the most practical use of two Arduinos, but it’s certainly impressive. You can pick up [Dustin]’s code over on GitHub.
I2C master and slave. Nicely done. I wonder what kind of latency this adds, if it’s negligible or not.
a multi-core microcontroller with more pins than you’ll ever need.
Challenge accepted.
im already burning through pins on an animatronic head
I wrote the lib and don’t want to sell it short, but I also don’t want to oversell it. :)
The latency is not “negligible”. Do the video frame by frame and you can see the client LED is a couple of frames or more behind the manager. For things that don’t require timing better than 10ths of seconds it should be fine.
Also, if you watch the whole video, you will see the client drops at least two frames. So it’s like 99.9% reliable.
Why is the library called ExtraCore if in fact (assuming the write-up above is correct) it has nothing to do with having an extra core? (i.e. you can’t offload tasks onto the other Arduino — make it do work in the background, etc…)
What is the advantage of spending $30+ on another Arduino when you could just buy a common bit-shifter for a $1. This seems silly… I mean, it’s cool that you did it — but, it’s hardly practical.
1. Bitshifters don’t have 6 channels of PWM output and 8 channels of analog input.
2. Now that you offloaded I/O to the second core, you can start thinking about other more complex scenarios like you describe. For example it would be trivial to add a smoothing function to the analog inputs, or debounce the digital ones.
3. My $10 Arduino compatible for sale on Tindie is called “ExtraCore” and this library is one of the usages I first envisioned for it so I wanted to code it up.
4. Yep, it was just a cool project to try. The code is free (beer) so please enjoy.
Handy, but this really isn’t “dual core”. Not even close, in fact. There’s no parallel execution going on here, the second Arduino just has its IO slaved to the first one. A similar thing can be achieved using the various SPI/I2C port expander chips already on the market, and for a fair bit less cash, too.
I second sdevvoodoo, dual core implies at least that there is shared program memory
“All these require extra components, though.”
but this doesn’t?
Every one has a second arduino in this days
Wouldn’t it be easier and cheaper to just get an arduino mega with plenty of extra IO already built in?
theres no *inbuilt* pwm control over the extra pins on the mega. That might be an issue for some projects, but in some cases, yes you are right.
Re: Isn’t a Mega. Easier? Almost certianly. Cheaper? It’s about the same price as adding a boarduino, rbbb, ExtraCore or whatever.
If you are much a hacker you can adapt the code to do more interesting dual core stuff easily.
Awesome (sic!) solution! If you can’t do it with one arduino, take 2, if 2 are not sufficient – take 4. And then we see buggu robots with over 18 arduinos at eurobot.
It’s fun to see what people do, instead of just taking a stm32f103zet6 or any other decent chip. It’s even worse then vendor lockin.
Oh yes, and and there are ready to use i2c gpio expanders, a lot of them and cheaper shift registers. If that’s not sufficient – expanding and i2c into gpio can be done on a cheap cpld with little to effort and can give you over 100 pins.
DUAL-MEGAS!!!
Seriously though, that’s what, 108 digital IO ports? What is the limit to this code? Could you do 3 or more arduinos?
If it really gives you access to the other Arduino’s peripherals, then it’s great. If it’s literally just adding them as GPIO, then it’s far less interesting and cost-effective. In either case, it’s an interesting example for I2C master/slave.
This is pretty cool – not because this is what I consider a good idea, but because someone took the time to do it. I’d think with a little work you could make the ‘slave’ code do other stuff at the same time (maybe monitor a matrix keypad, read/write to an SD card, etc while the manager is doing other stuff. You could add ‘virtual’ I/O pins to trigger functions on the slave – write a 1 to a virtual I/O that causes the slave to play back a complex sequence of events, etc.
That said..
I’ll leave this link right here:
https://www.sparkfun.com/products/8130
I heard you like fail with your fail….
When will the Arduino crowd realize that you can just take any 40 pin AVR mega, throw it on a breadboard, protoboard, or PCB, and download code to it?
yes, but it’s the standardized hardware and community that makes it worth it to some people.
ATmega is standarized and Arduino isn’t adding much more than that (power supply, oscillator, rs-232 usb interface). Getting Arduino code working on bare ATmega is just the matter of burning in a bootloader.
MikrySoft: Your comment is completely correct, and with no side effects, so long as you forget that fully 50% of the Arduino audience does not KNOW what a “bootloader” is.
Arduino is a package of usability for non EE types. This fact is presented in nearly every article written about Arduino.
In every HAD post there are always techies who keep missing the point, and pointing out the obvious that [insert other processor/platform here] can do the SAME job for [less money/fewer parts/less power/other favorite micro platform here], where inevitably the “other” thing lacks the Arduino IDE, bootloader, or shields community.
I think the real question is, what is the maximum number of Arduinos you could control with this?
As written, just one. It’s technically dual master i2c. Lazy of me, I admit. If you did the work for the master to query the clients like i2c is supposed(?) to work, then you could chain a ton of them.
Repost? http://hackaday.com/2011/11/08/a-simple-method-for-expanding-arduino-io-capacity/
I wanted you all to know my newest project involves multicore PC computers, I connect 2 PCs to gain additional LPT port!
I would like to see this done with an attiny 84 or similar. There have been lots of times I don’t need the power of a 328 but I need more pins than are available on the smaller, cheaper, chips.
Attinyx5 doesn’t have hardware i2c like the xx8 chips. http://www.atmel.com/Images/doc2586.pdf
It possible to do in software of course, but harder. Of course, DigiSpark wrote USB into the bootloader on the Attiny85, so i2c should be doable.
Attiny84 I meant the attiny84 specifically.
http://www.atmel.com/devices/attiny84.aspx?tab=parameters oops link broke first time around.
I see. Sorry for being dyslexic about the chip. Sure you could adapt it to the Attiny84. Wouldn’t be terribly hard.
Just use HC164D!
A shift register? Those are ok and all but it would be nice if the slave chip had some logic capabilities of its own. Not to mention the smaller attiny chips are cheap enough to be thrown just about anywhere you might consider using a shift register/IO expander.
Wow, for about $30 you can emulate about $4 worth of i2c I/O expanders and waste about $24.
Got a blog post or Instructable detailing how to do that? I’d love to take a look. Buy the way you can get Arduino compatibles to use as an extender for ~$10. So you would only be “wasting” $6.
And if you can get away with just a Atmega88 or less then you would be “wasting” less then $2 which costs less then i2c I/O expanders for the same number of IOs. You can even share the xtal so you just need the IC same as if using an expander.
I made the conclusion a while ago that it was better to use an extra atmega chip then i2c I/O expanders, but I offload some of the smarts to the secondary boards too (mostly sensor code)
Wow you’re pretty quick if you paid $30 for your ExtraCore! I’ll sell you mine for HALF OFF, $15! I’ll even buy 10 of them and sell to you at that price.
Thanks AC. :D Maybe I should raise the price instead of lowering it?
I haven’t tried this, but I think that I might build a couple of my own Arduinos on a breadboard to make a dual-core one for less than the price of one :D
I have expirimented with ExtraCore and I think it is brilliant! The only problem with it is that it is so limited due to the slow speed of I2C communication. I am using two arduino Mega2560 boards and found that my PWM pins wouldn’t all work. Found that the pins have to be the same as the Uno! If the library was written to utilize the SPI communication, I think the Mega could be used with all the pins and run much faster. How hard would it be to create the library to work with the SPI bus instead?
I like it, despite the points made by the “not really dual core” crowd. I believe it can add:
Offloading some libraries onto the second core if you get creative with the setup, more eeprom to dump into using functions and predefined instructions, more pins of all sorts, 2x the total current output by spreading the outputs over 2 chips, and a library (which expanders don’t generally come with).
Less hating, where’s your dual core microprocessor library at?