Hi
I am new to programming and have been through a lot of the basic beginner arduino tutorials. I'm working on my first 'real' project. What I need to do is set a stepper to turn X amount of steps, then fire and IR LED. Then wait for X secs (while a camera takes a pic) and repeat for X number of moves (a full rotation). I would also like a 'manual mode' where I press a button and it does one move and one IR flash.
Now I have a sketch working for the stepper and I have a sketch working for the IR flash (to camera). My problem is combining the 2 sketches to make one synchronised routine. As a beginner, I don't even know what to Google for. I think in basic terms I need this to happen:
1. 'Start Button' is Pressed
2. IR Flashes/Camera Shoots
3. Wait for 2 secs for camera to process
4. Motor Turns 10 degrees
5. Wait 5 secs for motor to turn
6. IR Flashes/Camera Shoots
7. Then Loop 3, 4, 5 & 6 35 times.
8. Stop (maybe make a sound at stop).
I do want to learn this, but I'm stumped as to where to start. The two sketches I have working are:
IR to Nikon - Example by LadyAda
int IRledPin = 13; // LED connected to digital pin 13
void setup() {
pinMode(IRledPin, OUTPUT);
}
void loop()
{
SendNikonCode();
}
// This procedure sends a 38KHz pulse to the IRledPin
// for a certain # of microseconds. We'll use this whenever we need to send codes
void pulseIR(long microsecs) {
// we'll count down from the number of microseconds we are told to wait
cli(); // this turns off any background interrupts
while (microsecs > 0) {
// 38 kHz is about 13 microseconds high and 13 microseconds low
digitalWrite(IRledPin, HIGH); // this takes about 3 microseconds to happen
delayMicroseconds(10); // hang out for 10 microseconds, you can also change this to 9 if its not working
digitalWrite(IRledPin, LOW); // this also takes about 3 microseconds
delayMicroseconds(10); // hang out for 10 microseconds, you can also change this to 9 if its not working
// so 26 microseconds altogether
microsecs -= 26;
}
sei(); // this turns them back on
}
void SendNikonCode() {
pulseIR(2080);
delay(27);
pulseIR(440);
delayMicroseconds(1500);
pulseIR(460);
delayMicroseconds(3440);
pulseIR(480);
delay(65); // wait 65 milliseconds before sending it again
pulseIR(2000);
delay(27);
pulseIR(440);
delayMicroseconds(1500);
pulseIR(460);
delayMicroseconds(3440);
pulseIR(480);
}
Stepper - Example by LadyAda
#include <AFMotor.h>
AF_Stepper motor(200, 1);
void setup() {
motor.setSpeed(5); // 10 rpm
}
void loop() {
Serial.println("Double coil steps");
motor.step(6, FORWARD, DOUBLE);
}
If someone could just give me a clue as to which commands I need to be using or if my predicted routine is correct?