Ok everyone, Im stuck with some camera slider shutter code.
I recently acquired a camera slider and I want to use a stepper motor (bipolar) and the Arduino motor shield.
My code is meant to do:
Check the Pot value to set the speed of slider
Then Move the slider 1 interval
Then Focus the camera
Then Release the shutter
Then Repeat.
Currently I have an LED wired up and it seems to be registering the shutter, which works but the stepper motor is not working as it is not moving.Im using the Arduino motor shield.
Does anyone know whats wrong with the code.
Also the Potentiometer doesn't seem to be registering on A0 when the wiper (middle pin) is in A0, +,- on the other pins.
const int c_focus =2;
const int c_shutter =4;
int cfocusdelay = 300;
int cshutterdelay = 300;
int betweendelayC = 100;
int PotPin = A0;
int val = analogRead(PotPin);
int delaylegnth = (val);
void setup() {
//establish motor direction toggle pins
pinMode(12, OUTPUT); //CH A -- HIGH = forwards and LOW = backwards???
pinMode(13, OUTPUT); //CH B -- HIGH = forwards and LOW = backwards???
//establish motor brake pins
pinMode(9, OUTPUT); //brake (disable) CH A
pinMode(8, OUTPUT); //brake (disable) CH B
pinMode(c_focus, OUTPUT); // Focus Camera
pinMode(c_shutter, OUTPUT); // Triggers Camera Shutter
pinMode(PotPin, INPUT); // Input for Potentiometer
val = map(val, 0, 1023, 10, 30000);
val = constrain(val, 10, 30000);
}
void loop(){
digitalWrite(9, LOW); //ENABLE CH A
digitalWrite(8, HIGH); //DISABLE CH B
digitalWrite(12, HIGH); //Sets direction of CH A
analogWrite(3, 255); //Moves CH A
delay(val);
digitalWrite(9, HIGH); //DISABLE CH A
digitalWrite(8, LOW); //ENABLE CH B
digitalWrite(13, LOW); //Sets direction of CH B
analogWrite(11, 255); //Moves CH B
delay(val);
digitalWrite(9, LOW); //ENABLE CH A
digitalWrite(8, HIGH); //DISABLE CH B
delay(35);
digitalWrite(c_focus,HIGH); //Focus camera ON
delay(cfocusdelay);
digitalWrite(c_focus,LOW); //Focus camera OFF
delay(betweendelayC);
digitalWrite(c_shutter,HIGH);
delay(300);
digitalWrite(c_shutter,LOW);
delay(val);
}
Thanks!!!