New to Arduino- Questions about the Arduino Nano and Mega

First a hearty hello...

Second, I know nothing about the Arduino boards other than I have seen people use them as FX controllers for some pretty nice Star Trek builds.

I have several Nano boards and am about to try out some sketches. Here are my questions:

What I am trying to do is control 10 Navagation lights, 6 strobe lights, 2 photon launchers, and phasers for a total of 20 or more LEDs that will flash or fire. My concerns with the Nano is there isn't enough outputs unless I double up LEDs on outputs. From what I have read, running multiple LEDs off one pin isn't recommended. I have read that it can be done, but again not recommended. I also read that the analog pins can be used for digital pins to control LEDs.

So my questions are can this be done with a Nano or should I go with a Mega? If I go with a Mega will Nano sketches work with the Mega?

I also have the Nano expansion board that adds screw terminals for easier connections, is there any type of screw terminal adapter for the Mega? I did find some out there but I'd rather not pay $50 or more for a screw terminal board. Last question, if there are no inexpensive terminal expansion boards for the Mega, are there male connectors and ribbon cables that work? I searched the web and couldn't find any 36 pin (2x18) cables with male connectors.

Thanks in advance, and I know this is a lot for my first post.

You can surely run 20 LEDs on a Nano by using something like a MAX7221 so, since you have them, you might as well try using them. A Mega can use Nano code, thereby making it look just like a Nano. You could easily expand that code to utilise the extra pins. There are screw terminal boards for Mega, or you could make your own.

Thanks for the fast response Nick.

I looked up MAX7221 and it is just a chip, I guess I'd have to build the circuit correct?

As far as the screw terminal board or kit, I spent well over 4 hours yesterday searching for this. I did find some places that made expansion boards and kits, but seeing that my Nano board terminal expansion board was only around $4, I thought $40 for a kit, and over $50 for an assembled unit was a bit much. Do you have any links to where I can source either a completed board or kit?

How big is this model? If you can fit a Mega and a screwshield, it must be pretty big.

You can't run large number of LEDs simultaneously directly from the Mega. While it has enough pins, it can't supply enough current to turn them all on at the same time.

Look at addressable LEDs. That way you can have full RGB colour control and only use up one precious output pin. It also allows separate power supply to the LEDs, so the current doesn't go through the Arduino chip.

Screwshields end up expensive because the good screw connectors aren't cheap. They are also relatively rare, so there isn't a lot of competition and bulk manufacturing driving down prices.

whb64:
I looked up MAX7221 and it is just a chip, I guess I'd have to build the circuit correct?

Yes. It would go on a proto shield. In your case of using a nano, I guess a solderable perf board is the obvious choice as it would take Nano as well, along with other peripherals, and there is no need to match Mega's pin pattern. The 70x90 ones like I use are about $5 for ten and would have room for 24 screw terminal pairs around the perimeter.

I thought $40 for a kit, and over $50 for an assembled unit was a bit much.

I think you're dead right...... You should be able to get the parts for about $5 or so. The most expensive component is likely to be the wire! Crossroads, on this forum, makes them but I don't know anything about them as I prefer to make my own on a blank rather than adapt to somebody else's thinking.

I don't know if the 7221 is the best choice, it is just one way of going about this sort of thing.

MorganS- These are 350 scale kits, which are around 3' in length. I am also doing 537 scale kits that are smaller.

I will be putting the board in the base display and not inside the model itself.

Nick I think I found what I need- I found 2 pin screw terminals that will fit in the header. I'm looking for the best price, right now I found some for .60cents, that may be the cheapest price I can find and isn't too bad. At least I think I found a solution for that :slight_smile:

whb64:
What I am trying to do is control 10 Navagation lights, 6 strobe lights, 2 photon launchers, and phasers for a total of 20 or more LEDs that will flash or fire. My concerns with the Nano is there isn't enough outputs unless I double up LEDs on outputs. From what I have read, running multiple LEDs off one pin isn't recommended. I have read that it can be done, but again not recommended. I also read that the analog pins can be used for digital pins to control LEDs.

So my questions are can this be done with a Nano or should I go with a Mega?

For the Arduino Nano, you can use NPN transitors to control multiple leds, like there are 3 transitors connected to 1 pin. DESCLAIMER: I have never tried doing this, so I have have no idea if it works. It might drive too much current and burn the processer.

You can also use SIPO shift register chips to control leds. You can control like, 8 leds with 2 pins using a shift register. And since the people who created the Arduino IDE and the Arduino Web Editor are smart, they made a function in the standard Arduino library called "shiftOut" for shift registers. Here is what I found in a book about programming Arduino:

Feeding Shift Registers

Sometime the Arduino Uno just doesn't have enough pins. When driving a large
number of LED's, for example, a common technique is to use a shift register chip.
This chip reads data one bit at a time, and then when it has enough, it latches all
those bits onto a set of outputs(one per bit).
To help you use this technique, there is a handy function called shiftOut. This
function takes four arguments:

  • The number of the pin on which the bit to be sent will appear.

  • The number of the pin to be used as a clock pin. This toggles every time a
    bit is sent.

  • A flag to determine whether the bits will be sent starting with the least
    significant bit or the most significant. This should be one of the constants
    MSBFIRST or LSBFIRST.

  • The byte of data to be sent.

Note: This book is based on the desktop 1.6.6 version, so things might be different.

If your wondering what book is this, it is: Programming Arduino Getting Started with Sketches, Second Edition by Simon Monk.

For both, you need to get a breadboard, witch is a bit bulky to your project.

Anyway, good luck on your project! :slight_smile:

I've decided to use the Arduino Mega for the big ships with a lot of lights to control since it has 54 outputs. That seems to completely resolve that issue. I'll use the Nanos in smaller builds.

Now all I have to resolve is an inexpensive way to convert the headers to screw terminals. I found some 2.54 pitch terminals, but I am not sure is the terminal itself is small enough to get them all to fit on the header. My guess is they aren't.

I'm sure you have guessed right. Screw terminals are typically 5.08 spacing, and the 2.54 you previously alluded to is likely to be that they simply fit on a 2.54 pitch matrix, and never made to go into a header.

As in reply #4, you could use a 24x36 perf board sitting on the Mega, starting at A0, and carrying the screw terminals in your choice of colour, grouping, location etc.

Do all the led's need to be individually addressable?
If not then you could use the arduino to drive led drivers. For the drivers you could go crude and use relay modules or even look at led modules and replace the onboard leds with your own on wires. Both of these options need power that isn't sourced from the arduino ( you could probably tap the supply that feeds the arduino providing it has the amperage.).

krazydarcy:
Do all the led's need to be individually addressable?
If not then you could use the arduino to drive led drivers. For the drivers you could go crude and use relay modules or even look at led modules and replace the onboard leds with your own on wires. Both of these options need power that isn't sourced from the arduino ( you could probably tap the supply that feeds the arduino providing it has the amperage.).

No, which is one reason why I wanted to group them together.

For instance all the Navigation lights will flash at the same rate, and all the collision strobes will flash at the same but faster rate. So I have ten or twelve that flash at one rate, and six that flash at another rate. Then some FX lighting, upwards of six.

When I was planning on using the Nano I was trying to group them in sets of four, mainly to conserve the number of pins, but with the 54 pin Mega I don't have to worry about that.
Note: I won't be running any of them anywhere near the max voltage or amps. From the tests that I have done, these super brights can be run around half the rating and are plenty bright.

I probably should start a different thread for this next question, if I should just let me know-

I have the code for the photon torpedo effect, but the code uses two momentary switches, one for each launcher. What I want is to be able to control both with just one switch- when you push the button the first launcher ramps up and at the end of the cycle flashes brighter and then turns off, then immediately the second launcher goes through the same sequence. As long as you hold the button down the sequence will repeat. How do I control two pins with one switch as described above?

I can provide the code if needed and in the correct thread if required.

No problem to continue the discussion here.

You need a "state machine" which is another way of saying that the Arduino must remember what happened before. Start by looking at the Arduino examples in the "digital" folder.