Newbie needs assistance

I will be creating a model of the uss enterprise and it will have a custom lighting and shuttle bay doors built into it.

heres the plan

stage 1: start up
Start up sequence
primary hull - immediatly on
secondary hull - immediatly on
deflector dish - fade on to standby 2 second fade to 100%
necells - N/A
Impulse - Fade on "standby" 2 second fade to 100%
Shuttle bay fade on 4 second fade to 100%
RCS thrusters - fade on 50% brightness
Flood lights immediatly on
Torpedo launchers - Immediatly on
Shuttle bay doors open

Stage 2: impulse power
Deflector "standby" orange 100%
Impulse "active" Red 100%
Necells "standby" off
RCS thrusters fade 100% brightness
Torpedo launchers immediatly on 100%
Shuttle bay: doors open

Stage 3: Warp power
Deflector "active" blue (fades to blue) 100%
Impulse "standby" (fades to orange) 100%
Necells "active purple" (fade on) 100%
RCS thrusters fade 50% brightness
Torpedo launchers Fade off
Shuttle bay: Doors close

Stage 4: Return to impulse
deflector "standby" orange (fades from blue to orange) 100%
Impulse "Active "red" (fade from orange) 100%
necells "standby" (fade off) 100%
RCS thrusters fade 100% brightness
Torpedo launchers fade 100% on
Shuttle bay doors open
Stage 2 through 4 on a loop until "shutdown sequence"

Stage 5: Shut down
All active lights fade off 25% per second.
shuttle bay doors close

Heres the thing, the doors are controlled by a small motor. There are also nagivation lights, that blink and white strobes included in the primary and secondary hull, the shuttle bay has landing lights and im sure theres more to it than that but havent realised yet.

I have absolutely no programming background and could use some help with this. I must note, i actually need to buy the arduino board but havent yet because i dont know what else will be needed other than wire, resistors and leds.

If someone can help me with this i would be forever grateful!

Oh, more questions.

I'm probably looking at approx 100 3mm leds of different colors here, so would the board need expansion boards?

like 1 expansion for flood lights, another for primary hull, another for secondary hull, another for necells, another for shuttle bay and so on?

I'm really green at all this haha.

Add up the number of "fade" channels and on/off channels you need. Count up the number of PWM (fade) and on/off (digital) channels on your Arduino and match them up. If you run out of PWM channels, digital channels can be made to do PWM but it's trickier than using a PWM channel. On/Off LEDs that are on and off at the same time can be on the same Arduino channel. I started to add up channels but got confused with the colors, fades, and on/off counts.

Make a spreadsheet and organize the LEDs by type (on/off, PWM), color, and when they need to be on and off and see if you have enough Arduino channels. If you run out, multiplexers can be added to increase the digital and PWM channel count but that gets more complicated. With a little creative matching you might be able to to everything with one Arduino.

okay so heres what i got.

I have no idea if a standard board has enough channels to allow this but if needs be an expansion can be used.

would it be possible to get some help with the prpgram side of it? I have no idea where to start and would rather get the software done before the hardware :slight_smile:

Would i be right in thinking that each channel needs to be programmed individually and timings set?

or can each channel be "assigned" then "blocks" or "stages" made up with "trigger links" to the assigned channels? so you enter in a list of channels and then program in the stages?

or have i got this all comepletely wrong?

How can a strobe light be always on? If is always strobing then it is flashing on and off.
The real always on LEDs can be connected to the supply through a resistor, the others need an arduino pin each.

Get a board and some LEDs and resistors, then look at the blink tutorials and learn what code is all about.

Its always on as in its "active" from power on to power off.

i think "always active" would have been better term for it.

I'm sorry, but the tutorial is full of notes mixed in with the code and i cant determine what is code and whats notes.

Then theres the landing strip lights, fade effects and how to get it all timed in together, how to trigger the motor, how to get certain stages to "cycle" and how to program the startup and power down sequences to react to the power button.

This is why i have asked for help

A line of notes starts with a double slash //
Many lines of notes start with /* and end with */
They will be a diffrent greyed out colour from the code.

You are not asking for help you are asking for someone to do it for you. Start of simple and work up to this do not try and do it all at once.

okay, that clears that up.

But please understand, im not asking someone to do it for me, Im asking for someone who can go through it with me as i gradually assemble the program.

however i do need to know where to start and generally how it should be assembled.

I.E how things should be grouped together or linked together.

I cant really write up the program if i dont know how to assemble the sections of it.

Does that make sense?

Get an Arduino and some LEDs and go from there...

Building an exact shopping list before starting is going to be difficult, but yes, you'll need some sort of expansion for all those LEDs (probably a set of TLC5940 chips on a circuit board).

If I was you I'd get an Arduino starter kit. They have an Arduino with breadboard, wires, LEDs, some motors, etc. Everything you need to start learning. Google "arduino starter kit"...

eg.

however i do need to know where to start and generally how it should be assembled.

When learning to speak a foreign language you start off by learning to ask directions. In practice this is no good to you because you can not use that skill until you have the skill of understanding the answers.

I could answer your questions and you would be even more confused than ever. You need to learn a bit of the language we speak here. You have good advice from fungus get some equipment and start playing with it. You don't start to learn an instrument by trying to play "the flight of the bumble bee", you start with something much simpler. Once you have one LED blinking you will know such a lot more.

I think you can do everything you want from an Arduino Uno without the need for any extra shields, you have 20 pins and each pin can control one LED or read a push button. Six of these allow you to fade LEDs so that is well within what you put on that spread sheet.

mike, We're talking about 150-200 leds here. Not one LED. Im unsure of the exact numbers at the moment but the excell sheet only really shows the different catagories of lights and their function. within each catagory theres alot of leds.

so going by what you have said i will be needing those expansions.

also, i need to get this started and off the ground. i dont have time to sit there and learn the language then go into programming this. I essentially need to learn the language as I write up the program which is why I have asked for help and not asked people to tell me to learn the language first.

secretreeve:
also, i need to get this started and off the ground. i dont have time to sit there and learn the language then go into programming this. I essentially need to learn the language as I write up the program which is why I have asked for help and not asked people to tell me to learn the language first.

Ok, so pick a starter kit and get it ordered. You can probably use 90% of the kit in your model so it'll be cheaper than buying separate parts.

Next google "TLC5940" and start reading. Each one can control 16 leds from an Arduino with PWM. Go on eBay and order a dozen of those and a bag of mixed color LEDs. When it arrives and you have it working you can get some suitable size "prototype board", etc. to build the final gadget.

I essentially need to learn the language as I write up the program

This is impossible, it is too complex.

i dont have time to sit there and learn the language then go into programming this.

Then you don't have time to do this project, how about taking up knitting?

which is why I have asked for help and not asked people to tell me to learn the language first.

But you said:-

But please understand, im not asking someone to do it for me,

It sounds to me like you are.

OK here is what you need to do:-
Connect a bunch of shift registers and run the shift library:-
http://www.elcojacobs.com/shiftpwm/
The rest is trivial.

Grumpy_mike. I honestly cannot help but feel your making things more complicated that they need to be. Our wonderful language does include a way to portray information in lamens terms. However that link is very useful, thank you.

My only concern would be controlling say, led 10 then say led 1 then 16 in that order. but im sure its possible with that setup.

Its not impossible to learn programing as you do a project, I learnt programing a HD47780 screen with the RPI while working through that project.

Fungus, thats awesome. thank you. I assume that can be made to control the LEDs on the pin outs in a certain order or all together? Not used that chip before so it will be new, I have the data sheet to read through today for it though.

Okay, lets see if this sounds correct to you guys.

one shiftregister per catagory of lighting with its capacity expanded to accomodate the led quantity for that cagatory. But using the chip Fungus said for the primary hull and secondary hull lighting as these are on all the while the models lights are on. they only turn off when everything else is shut down.

Each shiftregister assigned to a specific output on the arduino.

Then program each stage into the arduino similarly (but in code) to how its laid out in my first post, Then from there set the cycle loop code and then worry over the push button triggers for start up and shut down as well as the motor triggers?

does that sound right?

so the first block of sort in the program would have the pmw settings for deflector, impulse, necelles, RCS thrusters and torpedo launchers?

and pretty much that for stages 2-3-4 then come back and work on stages 1 and 5 right?

does that sound right?

No.

one shiftregister per catagory of lighting with its capacity expanded to accomodate the led quantity for that cagatory. But using the chip Fungus said

There is only one place you can connect a TLC5940 to an arduino, if you want more you will have to chain them.

Each shift register assigned to a specific output on the arduino.

No that is not the way it works so you can use a shift register and dim them, unless you want to re write the shiftPWM libary then you can't do it.

Then perhaps instead of just saying "no" you can elaborate somewhat on things.

Do you talk down to all new people to this? Or are you just sour? So far all I have seen is one useful link and no no no.

It would be extremely helpful if you explained the best way to lay out the stages as thats the first part and frankly I dont know where to start.

I dont have access to the board right now but I do have access to the programing software. I would just like to get a start on this while I wait for the board to come.

Its really not so much to ask now that someone points me in the direction of where to start and how to group stage 2 together.

Funny thing about software, it's not always dependant on you having the relevant hardware immediately.

Still cant work out if by rewrite the shiftregistry you mean bung that on an arduino and write the entire program into the shiftregistry or what.

In all honestly, I'm wondering if arduino is even the right platform for this in terms of keeping it simple.

secretreeve:
Fungus, thats awesome. thank you. I assume that can be made to control the LEDs on the pin outs in a certain order or all together? Not used that chip before so it will be new, I have the data sheet to read through today for it though.

Each LED is individually controlled. Use the library.

You connect all the TLC5940s together as a chain, they're designed that way.

You probably want to go through the list and figure out what basic functions are required and look into your hardware to see how that can be achieved.

For example, you seem to need to turn on / off lights, fade lights, turn on / off motors, control timing, etc.

I would suggest that you expand that light and then assemble them together to perform individual stages.

Take this as an example. Let's say that your led is active low. You can write an led on/off function like this:

#define LED_ON(pin) digitalWrite(pin, LOW) //turn on an led, active low
#define LED_OFF(pin) digitalWrite(pin, HIGH) //turn off an led, active low
#define LED_BLINK(pin, duration) do {LED_ON(pin); delay(duration); LED_OFF(pin);} while (0) //blink a pin for a given duration

//perform stage 1 activities
void stage1(void) {
  LED_ON(LED_ORANGE); //turn on orange led
  LED_OFF(LED_RED); //turn off red led
  MOTOR_ON(FLIGHT_DECK); //turn on flight deck motor
  delay(DURATION_1s); //for a second
  MOTOR_OFF(FLIGHT_DECK); //turn off flight deck, after a second
  for (i=0; i<20; i++) LED_BLINK(LED_FLIGHT, 100); //flash flight led for 20 times x 100ms
  ...
}

Just some examples.

Think of programming as building a house with lego blocks: you have to figure out what those little blocks are and then assemble them together.

Dhenry, that is fantastic!

That gives me some idea on where to start so I VERY much thank you as it's exactly what I was needing, that little nudge in the direction of the beginning!

I'll take a look into the arduino software and see what I can come up with.

Just breeze over this quickly, does someone have a link to adding push button controls that I can bookmark for later?

I'll have a bash at knocking something together and post it up. See if I'm along the right track there.

Although I do still have questions about expanding the arduino.

Ideally I would like to be able to add a board to each channel which basically just allows me to up the number of LEDS per channel without IC's and so on. So the channel on the arduino would act more like a signal to the "booster board".

That shouldnt be too difficult should it?