Multiple tasks with one board

Hello everyone,

I'm all new to Arduino stuff and pretty excited about what can be done with such cheap and small hardware! I'm really looking forward to play with it (I've started already but am waiting for a few wires to go further).

There's something that I'm wondering though. Every example of code that I see handles virtually one single task.
For instance, get a value from an INPUT (light sensor, ...) and do something on an OUTPUT (LED, ...).
Can one board be used for multiple purposes (tasks) ?
For instance if I want to have my board report temperature every hour and react permanently to a switch state change (both tasks followed by a remote ethernet connection to send information).

I am actually able to visualize how the code would look like but I want to ensure I'm not going to wrong way.

Also when you tested your project successfully using a breadboard, how do you guys finalize it ?
Do you have someone creating a special board that you can plug onto your arduino (or externally using wires) ?
What do you do in regard to cases ? Do you create them yourselves ?

Thank you for your time!

dynek
Welcome to Arduino
Most of the "published" code has an educational or simplified side to it. Having completely distinct functionality in one sketch doesn't help the education.
There are no other limits then CPU power, memory and pins. There is no reason why you could not handle the example you are giving. One advice though: The more you want to do in parallel the more you have to stay away from the delay() functionality.

As to put it in a box. Each project has its own specifications (shields, cables, water resistance, UV...) so there is no one size fits all. There are some threads on the forum with examples. Using the search functionality should help you.

I hope this helps
Best regards
Jantje

Thank you for your answer Jantje.

Your answer sure helps. Thank you for your time.

I will dig into the forum and play as much as I can with my new toys :slight_smile:

Can one board be used for multiple purposes (tasks) ?
For instance if I want to have my board report temperature every hour and react permanently to a switch state change (both tasks followed by a remote ethernet connection to send information).

Yes, of course.
Probably the single most useful example, and one of the simplest, is the "blink without delay" tutorial.
The code is tiny, but the implications huge.

AWOL:
Yes, of course.
Probably the single most useful example, and one of the simplest, is the "blink without delay" tutorial.
The code is tiny, but the implications huge.

Excellent suggestion! Thank you.

To handle multiple tasks, you have mostly two directions : sequential or interrupt. The first one is simple : just concatenate the tasks' code in the "loop()" and everything is done in sequence. Nothing specific to care about, except indeed that "delay" stops everything.

The second one is more complex, but can do more : you create a small routine that gets called when a specific event (interrupt) takes place.

See http://www.codeproject.com/KB/system/Arduino_interrupts.aspx or http://www.arduino.cc/en/Reference/AttachInterrupt to get started.

About cases/final designs etc, I fully agree that Arduino is weak in that respect. The only boxable product I know is Duinomite (but even there, it looks like thebox won't be usable if you plug a shield ...)

tochinet:
The second one is more complex, but can do more : you create a small routine that gets called when a specific event (interrupt) takes place.

See http://www.codeproject.com/KB/system/Arduino_interrupts.aspx or http://www.arduino.cc/en/Reference/AttachInterrupt to get started.

This is very interesting. Even if I read the hardware page with care a few times I never realized about the interrupts!
Thank you!

You can build "Arduino" into your projects in many ways.
If there are only connections to be made and little or no additional hardware is needed then a board like this
http://store.nkcelectronics.com/arduino-runtime-board-rev-b.html
can be built up using a pre-programmed part (i.e. programmed in your Uno for instance) and additional inexpensice components from a place like dipmicro.com, mouser.com, digikey.com, newark.com, etc.
If smaller is needed, build in a Promini, or a Mini-uino, pictured in my signature link.
Alternately, incorporate the ATmega & components onto a larger board with your other hardware, several examples of which are also shown at my link.
If you're not comfortable designing & building your own board to do that, there are several of us here that can design custom boards for you, and you can order them from a place like iteadstudio.com (ten 50mm x 50mm boards $9.90, ten 100mm x 100mm boards for $24.90, plus around $5 shipping), buy the parts yourself and learn how to assemble, or we can do the assembly for you and send back a tested board, all ready for you to download your sketch into. Often the designs are just variations of existing things and can be done in a couple of hours.
Or you can buy a kit like this and wire up your own.
Starter Component Set 132pc w/ Proto PCB - dipmicro electronics
This one is pretty complete, just needs a 16 MHz crystal, two 22 pf caps, and a 5V wallwart, all available from dipmicro also.

Lots of options.