ok I am a step closer.
#include <AFMotor.h>
int IRledPin = 12; // LED connected to digital pin 12
AF_Stepper motor(200, 1);
int NumberOfPictures = 5; // How many pictures should we take?
int CountVariable = 0; // I'll use this to keep a tab on how many pictures we've taken so far.
const int ButtonPin = 2;
int ButtonState = HIGH;
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Start!");
pinMode(IRledPin, OUTPUT);
motor.setSpeed(5);
}
void loop() {
if (ButtonState == LOW) {
Serial.println("Button Pressed");
if (CountVariable == NumberOfPictures) return; // Stop now as CountVariable indicates that we have taken the correct NumberOfPictures
RotateTT();
delay(1000); // wait half a second for good measure
SendNikonCode();
delay(1000); // wait half a second for good measure
CountVariable ++; // increment the count variable so it is actually counting :)
} // at this point it will go to the top of the loop at the void loop() line and start again.
}
// 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() {
Serial.println("Fire Camera!");
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);
delay(55);
}
void RotateTT() {
Serial.println("6 Double coil steps");
motor.step(6, FORWARD, DOUBLE);
}
I changed the 'int ButtonState = 0;' to 'int ButtonState = HIGH;' and now I have it where in the serial monitor it prints 'Start!' and pauses. But pressing the button does not do anything. I've double checked the wiring and tested the button with a separate sketch. My pin numbers are correct.