Bionic Arduino

Bionic Arduino is a set of four 3-hour classes in November 2007 hosted by Machine Project and taught by Tod E. Kurt. It is an introduction to microcontroller programming and interfacing with the real world using the Arduino physical computing platform. It focuses on building new physical senses and making motion with the building blocks of robotics, using Arduino as a platform.

In the class, participants are shown and experiment with the Arduino’s capabilities and learn the basics of common microcontroller interfacing, such as: digital output to control lights and LEDs, digital input to read switches and buttons, analog output to control motor position or LED brightness, and analog input to read sensor inputs.

The class assumes no previous electronics knowledge, though it does assume a little programming knowledge. No soldering is needed during the class, as all circuits are built with solderless breadboards.

Class Notes

Arduino Sketches Used in Class

Processing Sketches Used in Class

Parts Suppliers, New

  • SparkFun — Arudino board and shield, and many other neat gizmos.
  • Jameco — General electronic parts, easy-to-use, also has computer parts.
  • Digikey — Exhaustive parts supplier. Cheaper than Jameco usually, has more variation, more hard-to-find parts.

Parts Suppliers, Surplus

93 Responses to “Bionic Arduino – Introduction to Microcontrollers with Arduino”

but but …

umm… sitting in your class now.

32-channel servo controller

Hey one of the guys at the class mentioned ITC on Olympic in Korean Town as a cool place to pick up components and such. I can confirm this, and recommend it! The prices are… well it’s retail, so they aren’t fabulous, but they have a lot of good stuff. I didn’t see much in the way of ICs, but there were lots of LEDs/ Resistors/Caps/etc. a handful of kits, some tools, a decent wire section, and a big audio area that was mostly focused on the car. Worthy of a quick trip into K-Town, and a notable place to have on your list. Happy Monday!

Hey Todd,

I just found an osX implementation of php_serial.class here: http://www.geekymedia.com/phpserial.html as the original class didn’t include calls for darwin/osx.

I am running into weird problems with it, however, and have emailed the author to see if he has any suggestions (basically, it doesn’t appear to be opening a serial port, but every time I try to, I see my pin13 LED blink, so it must be doing something)

Hi Christin,
If you’re using an Arduino Diecimila, opening the serial port will reset the board on Mac OS X & Linux, so the pin13 blink is probably that. (and that’s a good thing) After opening the port, you need to wait a bit (around 1.5 seconds on Diecimila or 5 secs on older Arduinos) for the bootloader to timeout before you can send or receive stuff.

What sketch are you trying out? I’d suggest trying out something like the SerialHelloWorld and see if you can just receive characters being spit at you by the Arduino.

Hi Todd,

Great site. This has has been a tremendous help in finally understanding microcontrollers. I am an absolute newbie and now have my LEDs blinking morse code!

Question: How would you control multiple RGB LEDs with only the Arduino’s limited PWMs? Is the expandable without purchasing multiple Arduinos?

Thanks again!

Zac

Hi Zac,
Thanks, I’m glad you’ve found the class notes useful.

Controlling multiple RGB LEDs can be difficult, especially if you want to control their brightness. There are LED driver chips out there, but they can be hard to use.

I’ve been developing a solution to this problem that is called a “Smart LED”. You can read about them and the general concept of smart interface components in my Smart Interface Components talk slides.

In about a month we’ll have a type of Smart LED called “BlinkM” for sale. Each BlinkM is a smart RGB LED with 24-bit color control and an I2C serial interface, so you can control 127 BlinkMs with a single Arduino.

Hi Todbot,

Thank you, for the best class of electronic I have ever read.

Zmpulse (from France)

Hi Tod,

Thanks so much for posting all this info- it’s been a tremendous learning experience and a lot of fun.

I was able to modify the NunchuckServo code so I could access the other controller inputs- now I have multiple servos and both the buttons working- woohoo! But I do have a question about trying to smooth out the servo motion. I’ve changed the refresh rate and that definitely helped- any other suggestions?

Thanks!

Jerome

Hi Jerome,
You’ve discovered one of the hallmarks of sensors: noisy data. To smooth out the noise, the most common thing to do is to take a running average of the last N readings.
There’s an Arduino tutorial about this:
http://www.arduino.cc/en/Tutorial/Smoothing

Thanks! I’ll check into that before I go replacing the joystick with bend sensors…. :D

I really liked your lessons, only thing i want to know now is how i can use more led’s on one digital out….
your help oould be much appreciated.

greetz Job

Hi Job,

You want to be able to turn on multiple LEDs with one digital out? If you’re using red LEDs, you can put two (sometimes three) in series instead of just having one LED.

If you want to drive many more than that (or what to drive non-red LEDs), then you would use a transistor. See page page 20 of the Bionic Arduino Class3 notes for a brief description of this. The schematic would be:

You would need to adjust the number of LEDs and the resistor value depending on the color of the LED using Ohm’s Law (red LEDs are ~1.2V, green ~2.0V, and blue ~3.4V). I can help with some example scenarios if you like.

Alternatively, you can run the LEDs in parallel, by duplicating the LED+resistor sub-circuit as many times as you want, until you reach the current limit of your transistor. This has the advantage of you can keep adding LEDs without tuning resistor values and being limited by your source power. The above example uses 12V so you could stack LEDs, but the one below can just use the 5V on the Arduino board for as many LEDs as the Arduino has power for and the transistor has current capability for. The downside is you need a resistor for each LED.

I am learning the arduino…I am over loaded with info…I am looking for some one to do this with…are there any classes or seminars in the Chicago area ?

I am working towards controlling a set of motors that turn on the closer some one approaches the piece. Do you recommend the ultrasonic range finder, or the Infrared range finder ?

Much thanks
Christopher

Hi Christopher,
You should check out the Arduino Workshops forum on the Arduino site. In fact, it looks like there’s an Arduino workshop at the Chicago Dorkbot meeting on January 23rd!

Oh…I forgot

As some one approaches the piece, a motor will turn on the closer a viewer gets, so that when a viewer is 6″(or so) away, all the motors are on, but at, say 4 feet, only one is on. I am looking to learn, so any suggestions on code I can hack…

int ledPin = 13; // select the pin for the LED
int i=0; // simple counter to show we’re doing something

void setup() {
pinMode(ledPin,OUTPUT); // declare the LED’s pin as output
Serial.begin(19200); // connect to the serial port
}

void loop () {
Serial.print(i++);
Serial.println(” Thanks Again !”); // print out a thanks
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
}

//Christopher//

I know some of the guys at Dorkbot. I am there, dude.
thanks

I need at least 9 pwm enabled pins for a project I am working on using LEDs. What is the best way to get this done but have all outputs independent of each other?

I looked around and have not found any solutions that did not seam like overkill.

Thanks you for your time.

Hi Todd,
Not to blatantly advertise my own product, but if you’re looking to drive 3 RGB LEDs with Arduino, perhaps the easiest solution are three BlinkMs.

If that’s not what you’re doing, then you can recreate PWM by hand using really fast loops, like how the Sevo library works.

Thanks for the headstart with Arduino! And the tips about Wiimote I2C. I’m working on a robot car. And Arduino is so much easier and cheaper than what I was originally doing (Phidgets, Gamepad Hacks, etc).

Hi, Tod.

I’ve tried the arduino-nunchuck setup as per your instructions on the Bionic Arduino, and it works fantastic!

btw, I have one newbie question on the voltage input to the nunchuck.
May I use 3.3VDC ports of Arduino Diecimila insead of 5VDC?

Thank you for your wonderful lectures

Bryan

Hi Bryan,
I think it should work fine at 3.3VDC. In fact, the Wii Remote & Nunchuck’s I2C connection is supposed to be 3.3V and just happens to work at 5V with no problem.

Hi Tod,

Thank you for your helps.

Bryan.

Hi Tod,

I just came across your site and it’s fantastic! I’m starting to look over your class notes on Bionic & Spooky Arduino.

I have a question about using the Arduino for generating sounds. One of your projects has it play mp3’s (or wmv’s), but it looks like those are played by the computer and just triggered by the Arduino.

My question is, is it possible to have several short sounds stored in the Arduino’s memory and have it play those back from the Arduino itself (no computer involved, except for programming the Arduino of course)? And to have each sound triggered by a different input. I’m thinking of using something like that for a Halloween display.

Thanks in advance.
JimGf

Hi Jim,
Playing audio is right on the edge of what’s possible with the tiny microcontroller in an Arduino. But it is *just* possible. Lady Ada, who makes lots of neat Arduino kits is working on an Arduino shield that takes an SD card and plays WAV files. Here’s a pic of her work in-progress.

Hello again, Tod.

Thanks for your quick reply with pertinent info. I’m familiar with Lady Ada’s site – I just haven’t visited it lately, but I will now.

JimGf

Hi Tod, excellent site and lessons! Helping me remember a lot of high school physics i had buried away in the memory banks! :)

I’m doing an interactive installation as a research project, and have bought myself an arduino so i can use sensor readings through max.msp to control some video/sound. I’m using Windows XP sp2 and cannot for the life of me get the arduino environment to run. I’ve noticed in various forums many ppl with the same problem. It doesn’t run.
I get the error “the system cannot find the path specified”
After various trials with the run.bat file, trying to point it to the java directory, or copying the java files from c:program files\java to arduino folder, i get the error: “Exception in thread “main” java.lang.NoClassDefFoundError: processing/app/base”

Any ideas?! I REALLY want to start playing with it!

Thanks,
G

Hi GMacArch,
I don’t use Windows much, but in my little time with it, all I did was follow the instructions here: http://www.arduino.cc/en/Guide/Windows
That is, all I did was download the Arduino-win zip file, unzip it, and double-clicked on “Arduino.exe”. I’m not sure what “run.bat” does.

The above probably isn’t too helpful. I’d recommend posting your question in the Arduino forums. Lots of eyeballs to see your problem. :)

Good luck

HA!!!! All good! working fine now! Just did all your class circuits! :)

great stuff

Hi Tod,

What a fantastic site. Thanks for sharing all this information. As an aspiring programmer of microcontrollers this is a great starting point.

I have Tom Igoes books “Physical Computing” and “Making Things Talk”. I would love to add “Bionic Arduino” to my collection. Do you have any plans of publishing such a book?

Peace

Hi Ketil,

Thanks! Tom’s “Making Things Talk” is very similar to the book I would’ve written about Arduino. In fact, if you thumb through my “Hacking Roomba” book, you’ll see that many of the projects are similiar to what Tom had, but using the Roomba as the common device being controlled.

Hiya Tod.

Love this series – it’s really helped me explore the Arduino.

I think there’s a mistake in the PiezoKnock sketch. You call Serial.Begin with a value of 19200. This led to some strange output on my system. I stuck 9600 in there, as per usual, and everything was fine.

All the best, and thanks again,

Gareth

Hi Gareth,

Thanks, I’m glad you’ve found them useful.

The speed of the serial port should not effect any of the sketches I’ve presented. You have to make sure to match the speed in the Arduino application too. Since it defaults to 9600, perhaps this is what you’re seeing.

[...] motor connected to an Arduino. The finger is controlled with a Wii Nunchuck hooked up to one of Todbot’s WiiChuck Adapters. The tilt of the accelerometer in the Nunchuck moves the middle finger on the [...]

Hello. I downloaded your sketch for the nunchuck. But I get only values between 0 and 250 for x,y,z acceleration. Is this okay? I heard that one get values between 0 to 1000. How do I know if I accelerate the nunchuck to the left or to the right? I have not altered your code NunchuckPrint. I’d appreciate any help. Please. Sincerely, Alexander

Hi Alexander,
You are correct. The output of the nunchuck can be 10-bit (0-1023) but for most purposes an 8-bit number (0-255) is easier to deal with. You can see the code to get the 10-bit number here: http://www.windmeadow.com/node/42

To determine left/right tilt, look at the numbers from nunchuckprint and see how they move. You’ll see that one number has middle value that shifts from a min to a max, that’s the tilting from one direction to the other.

Thank you for your quick reply. :-) I tried to fetch an min and max value, but the values I got where in the same range whether I accelerated the nunchuk to the left or to the right. I read on some site that the idle value is 500, 300 is a sure left, 700 is a sure right…

Hello,

I am eager to try and connect the Wii Nunchuck to my Arduino Mini, and have it control a motor, but have very little experience. I guess my first question is: If I have a MOSFET (nte 2398) and I want to control the motor, is there a simple wiring diagram for this? Also, will you be teaching any workshops soon in the LA area?

Hi Aaron,
If you poke around the Arduino site & forums you’ll find many examples of people controlling motors with MOSFETs. Specifically, the DigitalIO page has a link to the Arduino booklet which has an example of how to hook up a MOSFET to control a motor.

Hi Tod,
I just had a quick question. Do you think it would be possible to have multiple Nunchucks connected to a single Arduino? I’ve been reading all your BlinkM articles (I really need to pop by Sparkfun and pick some up)about connecting them together on a common I2C bus and I wondered if it would be possible to read two Nunchucks on a single bus. I imagine the code could be a bit complex….

Thanks!

Jerome

Hi Jerome,
That’s a really good question. The I2C address of the nunchuck is hardwired to 0×52 (as far as I can tell). So if you hook up two Nunchucks and do a query as normal, you get back weird overlapping chunks of data. So you can’t do it that way.

The other thing one might try is to power up only one nunchuck at a time, take a reading, power up the other one, repeat. This also doesn’t work, as the unpowered nunchuck loads down the I2C lines inappropriately.

Two other techniques I can think of off the top of my head: using transistors to switch the I2C clock or data lines between the two nunchucks, or using other pins on the Arduino to act as an I2C master interface. Such a “software I2C master” bit of code exists out there for AVR chips so could work with Arduino. I spent a bit trying to get two of the most known to work and didn’t have much luck.

A few chip vendors (at least Maxim and either NXP or ST come to mind) make I2C switch/mux ICs that solve problems just like this one. They take one I2C bus and give you 2,4,6,8 buses in return (how generous of them!).

Some chips pass-through interrupts, while others don’t, so check the datasheets if you care.

You just put each of your same-IDed I2C devices on different buses and when you want to talk to one, you tell the switch which bus to address, send/grab the data, and so on.

The majority of these chips are SMD parts though, although I vaguely remember that some of the simpler parts *might* have been around in DIP/PDIP packages.

Oops, here’s one example:

http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=MAX7368EUE%2B-ND

Thanks for the response guys! I figured it would be something that would be tricky (if not impossible) to do as I would need to read data from both Nunchucks at the same time. I wonder if you could read separate functions from two Nunchucks at once- meaning that you only needed the accelerometer x axis from one Nunchuck and the y axis accelerometer reading from another, without having any overlapping readings. I guess I really just need to sit down and play with it.

This also begs the question as to when the Wii Motion Plus is available if an Arduino would be able to read data from both that and a Nunchuck at the same time. That would be cool. I know it’ll be a while before they’re released so I guess we’ll just have to wait and see…..

[...] nice set of tutorials: http://todbot.com/blog/bionicarduino/ [...]

Hi,

Really interesting tutorials here, especially the Wii peripheral interfacing. On this line of thought, is it possible to interface a Wii remote to a micro controller using the bluetooth HID interface? Say just using a bluetooth serial device such as a smirf or ESD200?

[...] Några tips om vilka sidor vi fick inspiration ifrån var. Arduinos Hemsida Todbot’s blogg med Arduino tutorials [...]

Hi Matt,
I’m pretty sure that one needs a fairly beefy microcontroller like an ARM or better to be able to run a Bluetooth HID host stack in order to talk to the Wii remote. Bluetooth HID is of the same complexity as USB HID. Those Bluetooth modules implement only the Bluetooth SPP serial profile, and that can be pretty simple comparatively.

[...] Spooky Arduino (básico), Bionic Arduino [...]

Just had to say, this is my one-stop-shop for all my diy controller needs. Excellent site, accept no other

Todd,

Great lessons!!! They really introduced me to the Arduino.

Are you going to release more?? Maybe an intermediate, Advance and expert level lessons??

Thank you for your hard work on these great lessons!

Hi Sparky,
Thanks! I might be teaching Arduino at Machine Project later this year, and hopefully it can be a bit more advanced.

What are some topics you’d like to learn more about? Also, feel free to ask any questions you might have about more advanced things here in the comments.

Tod,
Thanks for the quick reply!

I was wondering about “playing” a few different small .wav or .mp3 files with the Arduino and “Helper Chips” without having them attached to a computer to do so.

Also a lesson on different “Helper Chips”, their applications and construction would be great.

Thank you!

Yes, I love little helper chips (like, say the something like a BlinkM ;-)

Hackaday has been having a series of parts posts that cover some interesting “Lego-like” helper chips usable with Arduino and other microcontrollers.

Anyone reading this: what are some of the things you’d like to do or chips you’d like to learn how to use that go beyond basic Arduino knowledge?

[...] Arduino (atoms instead of bits for a change) [...]

Hey Todd,
i am successful with nunchuck and arduino.
It is really great !!! Thank you for your explanation of this all.
But my wireless nunchuck (from logic3: FreeBird Wireless Nunchuk for Wii, NW806) does not communicate with arduino.
Is there a solution?
Or is there a wireless nunchuck, which works fine with arduino?
Thanks.
Max from Baden-Baden, Germany.

Hi,

I’m having the same problems with the Logic 3 Wireless nunchuck. I have written my own code for the PIC to talk to the wired nunchuck, which works fine, bu the wireless nunchuck does not. I can tell you this, you have to initialize the wireless nunchuck after the data connect line goes high, however, I think the initialization process is different from a wired device. I hope to borrow a Wii soon so I can analyse the signal.

Hi Matt,
I also tried the wireless adaptor for nunchuck from “Bigben Interactive” which is
connected to the original wired nunchuck of nitendo and is wired to the arduino. It does not work. I initialed then the nunchuck when it was wired to the arduino and connected clock and data to the adapter without disconnecting ground and power. But this also does not work. I do not understand this. It would be great, if you
could analyze the initialization process of
the Logic 3 Wireless nunchuck.
I’ve looked for a solution long time in the internet. But I did not succeed. I don’t know, if a solution is known.
Good luck!
Max Manfred from Germany

I’ve also tried the Nyko Cord-free wireless nunchuck adapter and it also does not work. I’ve not looked too deeply into why these devices are not working.

Some potential reasons why that come to mind:
- I2C speed differences (100k vs 400k, Arduino is at 100k),
- need true 3.3V compliant signals (wired nunchucks operate at 3.3V but are 5V tolerant), or
- something to do with the “att” signal (pin 3) of the expansion port connector (Nunchucks don’t require this signal, but perhaps these wireless versions do)

Hi,
I’ve tested many different IC2 speeds and
I used 3,3V signals. But the Logic 3 Wireless nunchuck and the wireless adaptor for nunchuck from “Bigben Interactive” do not work. There is a connection, but the signals do not change, when the nunchuck is moved. Always the same series of data is arriving. Both wireless nunchucks behave in the same way.

hye there.. i am new her.. i want to know the microcontroller program for the ‘SMS through Telephone (AT89S8252)’.. if you dont mind.. could you please send the program to my email..
thanks..

I am having a problem with the Nuchuck sample I found here:
http://todbot.com/arduino/sketches/NunchuckPrint/NunchuckPrint.pde

When I have connected the Nunchuck, there is no response at all. I mean, when I open the serial monitor, no data is displayed.

When I disconnect the Nunchuck and run the sketch it does run. It shows the columns that are printed nicely, but of course all values are zero.

I have checked if the Nuchuck is working correctly by connecting it to the Wiimote and do some boxing, it works.

I am using a Wiichuck from fungizmos.com to connect the Nunchuck to Arduino: http://store.fungizmos.com/index.php?main_page=product_info&cPath=69&products_id=212

If I am correct, that is product designed by you.

According to that site, analog pins 2 (gnd) and 3 (pwr) should provide power to this little adapter. My multimeter doesn’t show any power though. Shouldn’t the sketch contain some code that sets pin 3 high? Also with no Nunchuck and no adapter, I have no power on Analog pin 3.

I am stuck…

Any idea’s?

Thanks in advance!

Hi CrashingDutchman,
Try re-downloading NunchuckPrint and trying it again. That sketch was written before I made the Wiichuck adapter you got from FunGizmos. I just updated it (and NunchuckServo) so they both set analog pins 2 & 3 as gnd & pwr for the Nunchuck.

You can find more info on the wiichuck adapter you got from FunGizmos here:
http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/

Thanks Tod, that did the trick!

Hi. I just got my first set of Arduino and those slides really helped me a lot for studying how use them.
Thank you very much.

hi todd, great and neat tutorials!
but after my arduino set has arrived and after a bit of soldering on the motor shield, i’m still stuck :(
i don’t know how and where to connect servo motors to!
i’m wandering the internet searching for instructions on how to use the shield properly.
could you give me hints on it?
thanks a lot for your tutorials 1st and for any suggestions you could give ;)
atb
.rik

Hi Rik,
Which motor shield did you get? If you got the Adafruit motor shield then she has posted several examples and other instructions. For example, on the Use It page for the shield, there are several different example Arduino sketches.

thanx for quick reply, todd.
i regret i didn’t get that one ’cause i found several info on it.
till now i could say i unfortunately bought the ‘original’ arduino shield, the one pictured on the main .cc site.
the problem is that the version i have (v3.0) is newer than the one showed there and i cannot find any info(still searching) on it.
furthermore i have those switches and the third chip, only designed on the pcb (not present in the picture).
i know it’s extremely powerful but as far as i can look for info, i still can’t find any.
thanx again
.rik

Where did you buy it from? Are there any names or URLs on the shield? I’d email the place you bought it and ask them. Also, post on the Arduino forums. It looks like someone else had a similar problem and maybe had a solution.

I bought it from http://www.smartprj.com/;
The name written on the pcb is David Cuartielles(as quoted in the forum) and the url points to the arduino.cc site.

I looked at forums but, avoiding the soldering details, nothing leads me to connections instructions.
From further reading (http://arduino.cc/en/Reference/Servo), i only know i can connect servos to pin 9 or 10 on the Arduino board itself and i guess i could do the same on the shield.
But i wonder: what do i need a shield to drive motors for?
As you can easily guess i’m quite a newbie in electronics and i sure need a deeper reading on all arduino stuff but i can only find little news on few things.
What would you suggest? Go fishing? ;)

thanx
.rik

If you’re controlling standard servos, you don’t need a shield at all, just a breadboard, as is discussed in the class notes linked above. Servos have built in electronics to do all the hard work for you. And you can connect a servo to any digital pin, not just pins 9 & 10. The Servo.attach() method lets you pick which pin to use.

You can also drive motors with a simple circuit consisting of a transistor and a few extra parts (also described in the notes above)

The reason why many people use a motor shield is to have a more complex circuit called an H-bridge that lets you control the direction and speed of a motor. A motor shield might also have a provision for sensors (“encoders”) to determine how much the motor has turned.

here i am again
thanks for pointing this out

a further question: how could i let the shield work?
imagine i have a dc motor to attach to it, where do i get code to run it from the shield’s pins?

apropos, i wrote emails to those mentioned above but none answered ;)

sorry for disturbing

thank you

.rik

If you’re controlling servos or stepper motors, there are a few examples on the Arduino Tutorial page, showing how to use the Servo and Stepper libraries.

In the Arduino playground section on Interfacing with Hardware (linked from the tutorial page) there are several examples of controlling many kinds of motors.

Finally, in the class notes linked above and which this page is about, there is code and discussion on how to control servos and DC motors. For DC motors, the SerialMotorSpeed.pde sketch shows how to control a the speed of a DC motor hooked to any PWM pin. (which is how most motor shields will be hooked up)

If you’re not getting responses from the shield authors, post on the Arduino forum. There are many more people who read it than my blog and you’ll probably run into someone who had the same problem as you and has solutions.

Little Question:
Is it possible to send an integer from the serial monitor of the enviroment to the arduino ? (something similar to for example “197,DEC”)
Thanks.
Max from Germany

You mean send the single byte with value 197 and not the three characters “1″,”9″,”7″? In the serial monitor, I don’t think so. But there are many other programs to talk to serial ports. I create a really simple one in C, but perhaps easier would be ones written in Python, Ruby, or similar.

Hi Tod,

Just a quick note to say thank you! Great Arduino classes :)

Cheers from Holland,
Arthur.

Needless to say great tutorials – I am building a 6-wheel bot with my dad that needs to be remote (wireless) controlled. We wanted to use Xbees and the Adafruit motor shield (for 2 motors variable speed – forward and reverse) but they don’t seem to work together. We looked at double-wide boards but we are not sure they will work and we are not getting a reply to out emails (and the bluetooth Arduino is too costly). Do you have a suggestion for what we can use for wireless communication from a PC, or how we can get motor shields and Xbee together on a Arduino? Thanks in advance – Jules

Hi Jules,
What makes you say that the Xbee and motor shield won’t work together? I think you should be able to use an Xbee shield or Adafruit’s Xbee adapter with an Arduino motor shield.

If you’re concerned about how to connect multiple shields to an Arduino, the current standard practice is to stack Arduino shields on top of one another. Many shields come with “stacking headers” to enable this. Or you can get a stacking header kit from Adafruit or a stacking header kit from NKC Electronics. NKC also carries Xbee shield kits, in case you want to save some money on Xbee and like to solder.

Tod: Please help. We got our first Arduino, Adafruit’s motor shield kit and Xbees with Xbee adapter from NKC. When I look at this http://www.ladyada.net/make/mshield/solder.html We dont see how the motor shield and Xbee will work together with this Xbee shield: http://www.nkcelectronics.com/xbee-shield-remixed.html (from http://www.seeedstudio.com/depot/xbee%C3%82%C2%AE-shield-remixed-p-227.html) Thanks for your help. Jules ps: we got blink working and you would think we placed a man on the moon we were so happy.

Hi Jules, Ahh you’re right. Looking a bit closer, it appears that the motor shield and the most all Xbee adapters I looked at aren’t able to be stacked. This is unfortunate. You should send an email to Adafruit mentioning this problem. All the different Xbee adapters I looked at use the 6-pin ICSP pins, which is sorta oddball: most shields don’t need use that.

What you should be able to do, but it’s not as compact, is to use Adafruit’s Xbee Adapter Kit plugged into a solderless breadboard. See the bottom of the XBee adapter Arduino page for how to hook it up to an Arduino. (be sure to solder in straight headers instead of the right-angle ones)

[...] todbot blog  » Bionic Arduino – Introduction to Microcontrollers with Arduino Subscribe to comments You can skip to the end and leave a response. Pinging is currently not allowed. Post Tags: [...]

Tod:

This time you were right – the XBee adapter from Adafruit was easy to make and get working. There was really no need to stack an XBee shield on a motor shield. We used 4 wires from the XBee adapter right to the motor shield. We also used Limor’s tip to use the analog ports for digital ports 14-19 which worked out nice. We posted some details on http://sports4nerds.blogspot.com/.

Ps – now we have new problems – the h-bridge on the motor shield is not providing full power to our DC motors and overheating. We are going to try stacking another h-bridge or find another that can handle more amps.

Thanks again for your help.
Jules

Hiya Tod, love the site

I’ve been playing around with MAX7219’s and an Arduino Duemillanove, I’m wondering if you can tell me the theoretical limit of how many non-rgb Leds the arduino can control individually (with an external power source if need be).

Thanks
Mik

To be more specific I’d like to know the maximum possible amount of controlled LED’s from a Duemillanove with use of any trickery :) including shift registers, charlieplexing or any other chips. Cheers

Hehe, well Mik, if you put no restrictions on it like that, then the answer is basically: “as many as you want”.

When controlling LEDs there are usually two things you have to worry about:
- power draw — how much current needed for your LED array
- addressing — how to control a specific LED in your array

By saying external power source, you get around the power draw issues. An Arduino on a USB port can supply about 500mA of current. A standard LED draws max about 20mA of current. So you can have 500/20 = 25 LEDs off a single USB-powered Arduino. Of course, the Arduino chip itself can’t supply enough power directly to do all 25, you’d need some external driver transistors to help out. Or use LED driver chips.

As for addressing, an Arduino has 13 digital I/O pins. If you set those up as a matrix of 6 pins by 7 pins, you could address 42 LEDs with just the Arduino. But since you include LED driver chips and shift registers in the mix, those chips can do all the hard work and you just talk to them via multi-node serial protocols like I2C or SPI. There are LED driver chips which can address 24 LEDs at a time and are meant to be bussed together in a long string. So you could have maybe 100 of these chips and be able to have 240 individually-addressable LEDs.

But now you have to start worrying about logical addressing. If you think about what an Arduino program to control a few hundred LEDs would look like, you’d probably have a big array in memory, with each array byte is the brightness value of one LED. (many call it a “framebuffer” after what video cards do) A standard Arduino has 1024 bytes of RAM, of which about 256 bytes of this is used by various libraries like Serial. Your program’s non-framebuffer variables take up some of that too. So let’s just say that you have 512 bytes of RAM free for your framebuffer. That means 512 LEDs is your maximum.

Of course, if you don’t need to remember the value for each and every LED (like if you’re doing algorithmic stuff where a “next” LED value can be computed by a small number of “previous” LED values), then your memory requirements can be much smaller than one-byte-per-LED.

If you’re asking your question for more then theoretical curiosity, like say for a particular application, it might be better to say what you’re trying to do. Like most things in technology, there are many options, so the problem needs to be defined better so a solution can be properly fitted to it.

[...] * Bionic Arduino [...]

[...] that is regularly updated. What I have found really useful is Tods four 3 hour  arduino course: Bionic Arduino. The complete course documentation as pdfs with colour photographs is available for anyone to use. [...]

Something to say?