From d24649e7e4d3403ad7888e64e8c277a81dd7ca97 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sun, 5 Aug 2018 19:50:31 +0200 Subject: Initial import. Untested on real hardware. --- autopano1d.ino | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 autopano1d.ino (limited to 'autopano1d.ino') diff --git a/autopano1d.ino b/autopano1d.ino new file mode 100644 index 0000000..12185a7 --- /dev/null +++ b/autopano1d.ino @@ -0,0 +1,84 @@ +/* + * AutoPano1D, arduino sketch to take panorama photo driving a stepper motor and a wireless shutter + * Copyright (C) 2018 Ludovic Pouzenc + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +// Tested on an Arduino Nano with IDE 1.8.5 + +#include +#define SERIAL_TRACE Serial.println(__FUNCTION__) + +// Config +const int pictureCount = 12; +const int motorStepsPerRevolution = 200; +const int cameraStepsPerRevolution = 1000; // include external mechanic ratio +const int motorSpeed = 30; // rpm +const int cameraStabilizeDelay = 1000; // ms +const int cameraTakeDelay = 2000; // ms + +// Pinout +const int buttonPin = 2; +const int shutterPin = 12; +Stepper myStepper(motorSpeed, 8, 9, 10, 11); + +void setup() { + pinMode(LED_BUILTIN, OUTPUT); + pinMode(buttonPin, INPUT_PULLUP); + pinMode(shutterPin, INPUT); // Yes high-Z first, see takePic() + myStepper.setSpeed(motorSpeed); + Serial.begin(9600); // bauds + ack(); +} + +void ack() { + SERIAL_TRACE; + digitalWrite(LED_BUILTIN, HIGH); + delay(100); + digitalWrite(LED_BUILTIN, LOW); +} + +void loop() { + if ( digitalRead(buttonPin) == LOW) { + ack(); + takePano(); + ack(); + } +} + +void takePano() { + SERIAL_TRACE; + for ( int i=0; i