Pages: [1]   Go Down
Author Topic: Need Short Program Written Today  (Read 1581 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need a version of the code neccesary to make the prop dropper described here work.   http://www.nutsvolts.com/index.php?/blog/post/the_halloween_prop_dropper/

I can afford 30 USD

Functionality needed.

When triggered by a PIR a standard servo rotates 90 degrees, an LED is lit,  the program pauses 10 seconds, LED Off, a second continious rotation servo rotates for a variable time.  The variable time is controlled by a potentimeter.  Program ignores the trigger for 15 seconds and then monitors the trigger.

Contact me directly scarytinker at dslextreme.com
Logged

Kortrijk, Belgium
Offline Offline
Full Member
***
Karma: 1
Posts: 151
Young geek
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you still need it?

EDIT:
Here's a program to steer you in the right direction - I don't know how to drive a continuous servo:

Code:
#include <Servo.h>
Servo servo_normal;

int PIR_pin = 1; // port of the PIR
int pot_pin = 1; // port of the potentiometer
int LED_pin = 1; // port of the LED
int servo_normal_pin = 1; // port of the normal servo
int servo_cont_pin = 1; // port of the continious servo
int pot_value = 0;
int servo_value = LOW;
int servo_normal_value = 0;

void setup() {
  servo_normal.write(0);
  pinMode(PIR_pin, INPUT);
  pinMode(pot_pin, INPUT);
  pinMode(LED_pin, OUTPUT);
  pinMode(servo_normal_pin, OUTPUT);
  pinMode(servo_cont_pin, OUTPUT);

}

void loop() {
  servo_value = digitalRead(PIR_pin);
  if(servo_value = HIGH){
    // motion detected
    if(servo_normal_value == 0 || servo_normal_value == 90){
      servo_normal_value += 90;
    } else{
      servo_normal_value = 0;
    }
    servo_normal.write(servo_normal_value);
    digitalWrite(LED_pin, HIGH);
    delay(10000);
    digitalWrite(LED_pin, LOW);
   
    pot_value = analogRead(pot_pin);
    // add the continuous servo part here
    delay(15000);
  } else{
    // this will execute when there is no motion detected   
  }
 
}
« Last Edit: February 17, 2011, 03:54:18 pm by doublet » Logged

Sorry God members, I'm an atheist.

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wow!

Thanks!
Logged

Kortrijk, Belgium
Offline Offline
Full Member
***
Karma: 1
Posts: 151
Young geek
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You will have to add the contuous servo part yourself, as I said, I've never worked with one. Also, be aware that the 'rotate servo 90°' part will do that only once, I programmed it as you asked. However, in the video, it seems like it does that multiple times. This code should do like in the video:

Code:
#include <Servo.h>
Servo servo_normal;

int PIR_pin = 1; // port of the PIR
int pot_pin = 1; // port of the potentiometer
int LED_pin = 1; // port of the LED
int servo_normal_pin = 1; // port of the normal servo
int servo_cont_pin = 1; // port of the continious servo
int pot_value = 0;
int servo_value = LOW;
int servo_normal_value = 0;

void setup() {
  servo_normal.write(0);
  pinMode(PIR_pin, INPUT);
  pinMode(pot_pin, INPUT);
  pinMode(LED_pin, OUTPUT);
  pinMode(servo_normal_pin, OUTPUT);
  pinMode(servo_cont_pin, OUTPUT);

}

void loop() {
  servo_value = digitalRead(PIR_pin);
  if(servo_value = HIGH){
    // motion detected
    for( int loopvar; loopvar < 10; loopvar++){
      if(servo_normal_value == 0 || servo_normal_value == 90){
        servo_normal_value += 90;
      } else{
        servo_normal_value = 0;
      }
      servo_normal.write(servo_normal_value);
      delay(250);
    }
    digitalWrite(LED_pin, HIGH);
    delay(10000);
    digitalWrite(LED_pin, LOW);
   
    pot_value = analogRead(pot_pin);
    // add the continuous servo part here
    delay(15000);
  } else{
    // this will execute when there is no motion detected   
  }
 
}
Logged

Sorry God members, I'm an atheist.

Pages: [1]   Go Up
Jump to: