Help a nebie out?
How can I have one line of a sketch have a delay of say 30 seconds but not the entire sketch?
Im using IR to fire my camera and a stepper to rotate it also.They work great alone but not together. I want to be able to shoot more than one frame between rotation steps.
Heres my code:
#include <multiCameraIrControl.h>
#include <AFMotor.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// Connect a stepper motor with 200 steps per revolution (? degree)
// to motor port #2 (M3 and M4)
AF_Stepper motor(200, 2);
const int sensor1Pin = A0; // Yellow
const int sensor2Pin = A1; // Red
// White=Ground
Olympus E510(9); // (camera model E510) Pin 9 Hot IR LED Red Wire
const int ledPin = 13; // pin that the LED is attached to
int sensor1Value = 0; // the sensor value
int sensor1Min = 1023; // minimum sensor value
int sensor1Max = 0; // maximum sensor value
int sensor2Value = 0; // the sensor value
int sensor2Min = 1023; // minimum sensor value
int sensor2Max = 0; // maximum sensor value
void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH); // turn on LED to signal the start of the calibration period:
Serial.begin(9600); // set up Serial library at 9600 bps
while (millis() < 30000) // calibrate sensor during the first 30 seconds
{
sensor1Value = analogRead(sensor1Pin);
sensor2Value = analogRead(sensor2Pin);
if (sensor1Value > sensor1Max) // record the maximum sensor value
{
sensor1Max = sensor1Value;
}
if (sensor2Value > sensor2Max) {
sensor2Max = sensor2Value;
}
if (sensor1Value < sensor1Min) // record the minimum sensor value
{
sensor1Min = sensor1Value;
}
if (sensor2Value < sensor2Min) {
sensor2Min = sensor2Value;
}
}
digitalWrite(13, LOW);// signal the end of the calibration period
}
void loop() {
sensor1Value = analogRead(sensor1Pin); // read the sensor:
sensor2Value = analogRead(sensor2Pin);
sensor1Value = map(sensor1Value, sensor1Min, sensor1Max, 0, 255); // apply the calibration to the sensor reading
sensor2Value = map(sensor2Value, sensor2Min, sensor2Max, 0, 255);
sensor1Value = constrain(sensor1Value, 0, 255);// in case the sensor value is outside the range seen during calibration
sensor2Value = constrain(sensor2Value, 0, 255);
Serial.print(“sensor1:”); // lables input
Serial.print(sensor1Value); // prints the sensors values to the serial
Serial.print(","); // makes 2 columns
Serial.print(“sensor2:”); // lables input
Serial.print(sensor2Value); // prints the sensors values to the serial
Serial.println(",");
if (sensor1Value == 0,sensor2Value == 0)
{
E510.shutterNow(); // trigger the shutter
}
{
motor.step(1, FORWARD, INTERLEAVE); //CCW
>>>>> I NEED A DELAY HERE BUT ONLY FOR THE STEPPER<<<<<
}
}