Go Down

Topic: x-band motion sensor and arduino uno, help to connect (Read 745 times) previous topic - next topic

apocalyps

Hi! I've had problems to connect my new x-band sensor with my Arduino uno. I have a PIR sensor that works just fine, but i cannot get it work with the new sensor. Does anyone here have the knowledge of why it doesn't work. It seems as if the output from the x-band sensor is an oscillating signal and I think the PIR-sensor just give HIGH/LOW signal. The code I've used so far is presented below - my intention is to trigger my GoPro Hero 3 camera via the WI-FI-remote control.

As a note, I'm a complete beginner on electronics.


Cheers Martin

http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/32213-X-BandMotionDetector-v1.1.pdf


#include <avr/sleep.h>
int sensorpin = 0; //interrupt number 0, actually digital pin 2
int input = 2;
int film = 12; // output to control film, digital pin 13
volatile int state = LOW;

void setup()
{
  pinMode(film, OUTPUT);
  pinMode(13, INPUT);
  attachInterrupt(sensorpin, startfilm, RISING);
}

void sleepNow()         // here we put the arduino to sleep
{
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here
    sleep_enable();          // enables the sleep bit in the mcucr register
    /* Now it is time to enable an interrupt. We do it here so an

     * accidentally pushed interrupt button doesn't interrupt
     * our running program. if you want to be able to run
     * interrupt code besides the sleep function, place it in
     * setup() for example.
     * In the function call attachInterrupt(A, B, C)
     * A   can be either 0 or 1 for interrupts on pin 2 or 3.   
     * B   Name of a function you want to execute at interrupt for A.
     * C   Trigger mode of the interrupt pin. can be:
     *             LOW        a low level triggers
     *             CHANGE     a change in level triggers
     *             RISING     a rising edge of a level triggers
     *             FALLING    a falling edge of a level triggers
     * In all but the IDLE sleep modes only LOW can be used.
     */
    attachInterrupt(sensorpin,startfilm, RISING); // use interrupt 0 (pin 2) and run function
                                                  // startfilm when pin 2 gets HIGH
    sleep_mode();            // here the device is actually put to sleep!!
                             // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP
    sleep_disable();         // first thing after waking from sleep:
    detachInterrupt(sensorpin);      // disables interrupt 0 on pin 2 so the

                            // wakeUpNow code will not be executed
                             // during normal running time.
}

void loop()
{
//  delay(100000);
  sleepNow();
  if( state == HIGH){
    digitalWrite(film, HIGH);
    delay(200); //standard 200 ms, start recording
    digitalWrite(film, LOW);
    delay(6000); //filmad tid i ms
    state = LOW;
    digitalWrite(film, HIGH);
    delay(200);//standard 200 ms, stop recording
    digitalWrite(film, LOW);
  }
  else{
    digitalWrite(film, state);
  } 
}

void startfilm()
{
  state = HIGH;
}

Go Up