Hi,
I am new to Arduino and am in need of help. I do apologize in advance if I am not clear on what I am trying to achieve.
I am trying to use a Arduino Mega to control a Digital Camera (Mini DV). The Arduino is connected to a PIR which when detects motion sets Digital Pin 3 to High. The Digital Pin 3 is connected to a 1k resistor and a NPN Transistor (P2N2222AG) which is then connected to the record button of the Digital Camera which operates on its own 5V battery.
I am unable to trigger the record function.
The general picture of the schematic is included
https://picasaweb.google.com/lh/photo/9aj4dXb8Y5QwX-y3RRo83dX-t50N34v9Q3AjJRYm57o?feat=directlink
Code:
int ledPin = 13; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for PIR sensor)
int camPin = 3;
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status
void setup()
{
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input
Serial.begin(9600);
}
void loop()
{
val = digitalRead(inputPin); // read input value
if (val == HIGH) // check if the input is HIGH
{
digitalWrite(ledPin, HIGH); // turn LED ON
delay(150);
if (pirState == LOW) // we have just turned on
{
Serial.println("Motion detected!");
// We only want to print on the output change, not state
digitalWrite(camPin, HIGH);
delay(150);
digitalWrite(camPin,LOW);
pirState = HIGH;
}
}
else
{
digitalWrite(ledPin, LOW); // turn LED OFF
delay(300);
if (pirState == HIGH) // we have just turned off
{
Serial.println("Motion ended!");
// We only want to print on the output change, not state
digitalWrite(camPin, HIGH);
delay(1000);
digitalWrite(camPin,LOW);
pirState = LOW; }
}
}
Any and every help will be greatly appreciated.
Than you.