An introduction, and project assistance

Hi, I just bought my first (of many, I now assume) Arduino. It’s the Decimila model. I am brand new at the physical computing world, and have been devouring all of the information I can get my hands on about it. I have run through many of the tutorials, and tried some of the sample code that’s out there.
My new project involves an animatronic display for my next computer case mod, that I am working on.

Goals for my project/display:
Start up-
Servo #1 will move back and forth slowly nearly 180 degrees continuously.
Servo #2 will pan back and forth about 90 degrees
8 Chasing red LED’s will loop around and around

This will continue until Motion is detected
When Motion is detected
Servo #1 will quickly jump to home position and stop
Servo #2 will quickly jump to home position stop
(possible servo #3 will move about 30 degrees)
All 8 Red LED’s will flash
Small motor will spin
This will continue for ~30 seconds and reset back to start up

Parts
Arduino (Of Course!)
LED’s and resistors (I have tons)
For motion sensor, I was thinking of using these: http://www.parallax.com/detail.asp?product_id=555-28027
For servos I planned on using:
http://www.rctoys.com/rc-products/DF-SRV-9G.html
For the motor, something along these lines:
http://www.radioshack.com/product/index.jsp?productId=2102828&cp=&parentPage=search

Does this seem doable with what I have here? I have played around with the sample servo code provided on this site, and it seems like it should work, just curious how to make it all come together. Do I have enough outputs to do all of this with one board? Any suggestions? Code samples? I welcome your feedback!

The components seem fine even i think the servos might be a little small ... depending on application. You will need 11 digital and 1 analog pin ... the 3 servos have to go on PWS pin's so you can control them by writing out a pulse.

Other than that ... I would control the LED's with and int array and without the use of the delay function or you cant control them and teh servos simutianous. If you need a code sample let me know.

Thanks for the info! I'd love to see your code sample! I may step up the servo size a wee bit, but its only moving small 6-8" plastic parts, should be enough. Much appreciated!

Just a precision, you dont need PWM to control servos, any digital out is suffisant. servoTimer1 library use output 9 and 10 but not for PWM.

If i think about it jhoepffner is absolutly correct. It wouldnt really matter if the out is analog or digital since the whole thing needs to send a puls.

I will post an example this weekend. I am no guru myself and have to try this out before i give you tips that dont work. I will have something up by sunday.

Here is some code i use to controll LED’s (making them flash) without the use of the delay function

int ledpins = {5, 8, 9}; //set the ledpins that have LED’s
int interval = {150, 200 ,250}; // set the blinking interval fo each
int numleds = 3; // tell it how many led’s you have
long lastrun = {0, 0, 0}; // needs to have as many 0 as you have LED’s

void setup(){
for (int i = 0; i < numleds; i++) {
pinMode(ledpins*, OUTPUT); *

  • } *
    }
    void loop(){
  • flashlights();*
    }
    *void flashlights(){ *
  • for (int i = 0; i < numleds; i++) {*
    if (millis() - lastrun > interval*) {*
    _ //interval = random(25,150); this is commented out but you can use it for random intervals
    lastrun = millis();
    if (digitalRead(ledpins*) == LOW) {
    digitalWrite(ledpins, HIGH);
    } else {
    digitalWrite(ledpins, LOW);
    }
    }
    }
    }*

    Have fun_

You guys are the best! When I get some time over the weekend, I will post all of the code snippets I have for the various functions, and see if we can make sense of making them work together. Thats where I am totally lost.