Project question -multiple programs

Hello, Dimitri1990 from Canada.

I want to make this project, but I am unsure of a few things. I have never worked with microcontrollers before so I will have to do a lot of reading and learning.

a few questions, i would appreciate if someone would answer.

  1. can you run multiple programs on a microcontroller. NOTE only one at a time.
  2. can you switch programs with a on/off switch? or some sort of switch that can switch from the three programs. only one program runs at a time.

I mean that there would be 3 simple different programs that would control the same groups of LED's. The programs would not run at the same time. one would run the LED light squence, the other two would be off. Turn switch and next program runs squence. and so forth.

Is that possible? and which microcontroller would one recommend? Could a lilypad do this? or another type model?

these LED firing programs would be simple. LED lights would turn on/off. in a simple repeatable pattern.
For example one program would start with all LED's on, then from top to bottom the LED's would turn off, all LEDs of for a few seconds, then lights turn on starting from bottom. repeat. Can an aruino microcontroller could be used for this project right? but which one would be best? I will be powering a number of LEDs too. I'm not sure how big the program is. i guess i need to find out how many LED's I will be firing. I'm thinking up to 3 groups of 12 LEDs connected together. Maybe fewer. the groups would fire the same squence. IE all groups on, then start turning off from bottom, then all off, then hesitate, then on bottom to top. all on. repeat pattern. they could be wired together. i will have an extended power source. maybe wire them in parallel to reduce the battery weight. Oh Ya, this will be run with DC power. i will have a seprate power source connceted to the microprocessor that in turns runs the LEDs.

The other two programs are simular but one only envolves half of the LED's. the other one is a different firing pattern all together. But the groups will be all running the same program.

The thing is, I was thinking of using a Lilypad for this, but does a Lilypad only run one program at a time? would i need three seprate lilypads and three point switch to turn them on one after another? Is that an idea? i would have the lilypads grouped together with the one power source. make any sense?

I wanted to just have one microcontroller and put three programs in it and just use a three point switch to switch programs. I'm trying to make this as least complicated as I can. I'm afraid I'm new to all of this. I hope this can be done some how.

Any help of helpful suggestions would be appreciated :slight_smile:

~Dimitri1990

When you write and download a program in this environment you are doing this for one program only. However all that you want to achieve can be done in the one program by having three (or more ) different sections to the program and the appropriate section run depending on your input switches.
All computers run one program per processing core. Most computers have one processing core an look like they are doing several things at once by time division multiplexing, that is they chop what they are running so quickly that it looks like things are running at once.

With processors like the arduino you are running closer to the metal than a desktop but basically it is the same thing.

Hope that helps.

:slight_smile: hmmm yes that does help. I guess I have to do more research. i think i know what you are saying.

If I write a program with 3 parts in it, i could control which part runs at any time, with the proper control mechanism or input, in this case a three point switch or maybe a keypad with three keys in it. turn switch or press key and one part of the program runs.

So microcontroller on with on "power".
program runs, on repeat basic program (LEDs on all time)
press first key/turn switch first part of program (LED fire pattern)runs on repeat
press second key/etc second part of program runs (LED change fire pattern) on repeat
press third key/etc third part of program runs (LEDs change fire pattern) on repeat

press keys to switch or select programs.

Should I have a something inbetween the parts of the programs? IE press the key and all LEDs turns off for a second/ then full on, then run the selected firing pattern? like a reset. I'm not sure if this is need for LEDs. I wouldn't want to burn them out or anything.

I'll have to investigate which microprocessor would be the best one for my project. If i write the correct program without fatal errors it should work. Great! i can do this. I don't think my program will be that big.

All i wanted to know is if i need three seprate microprocessors, but no i don't. I can use one. with the correct program.

Thankyou for your reply. i'm new to this and all help is very much needed.

~Dimitri1990

You only need one microprocessor, you could do all you write about with a 15$ Arduino clone + a few switches and LED's and resistors.

In your program you can create different sections called functions, for instance one function for each of your different LED patterns (you can imagine a function as a " small program" inside the big program").

In the main part of the program you check the status of the switches, and call (jump to) the apropriate function.

My guess is that you are new to programming microprocessors, so i would recommend that you read Lady Ada's very fine Arduino tutorials here: Arduino Tutorial - Learn electronics and microcontrollers using Arduino! she does a very fine job explaining the basic stuff.

Yes, i have checked out the the Arduino tutorials and yes I and new to microcontroller programing. I'm sure i can learn how to do it. thankyou for your reply.

I think i understand how to have a function inside a program. which is very cool. it will make my project more effient and compact. :slight_smile:

This 15$ arduino clone you mentioned, where would be a place to get it? anywhere online?
i was going to buy a Diecimila for about ~40$ CAN from a shop in canada. i think it would be complete, I would have to hook up all the required wires to the LEDs and switche(s)/keys and download the program that i would write.

Dimitri1990:
I would highly recommend looking at: Arduino Tutorial - Learn electronics and microcontrollers using Arduino!

The 'final project' of this tutorial is almost exactly what you are describing: push a button and change the pattern of leds.

Give it a try and tell us what you think!

salernos

:)thanks! i didn't read through all of the tutorials, but looking at that last one, it is exactly what I want to do. Awesome. good get!
I'll have to start drawing up formal plans and get all my materials together. I will post my progress. super.

:smiley:

if you look at the little banner adds to the left on this site :

some of them are for people selling Arduino clones. Some are kit's you will have to solder yourself, some come fully assembled.

I don't se an add for Lady ada's shop, but she has an Arduino clone called Boarduino.