summaryrefslogtreecommitdiff
path: root/autopano1d.ino
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2018-08-05 19:50:31 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2018-08-05 19:50:31 +0200
commitd24649e7e4d3403ad7888e64e8c277a81dd7ca97 (patch)
tree84caf6d00a9e04b8ad41b92861cded5e3434b501 /autopano1d.ino
downloadautopano1d-d24649e7e4d3403ad7888e64e8c277a81dd7ca97.tar.gz
autopano1d-d24649e7e4d3403ad7888e64e8c277a81dd7ca97.tar.bz2
autopano1d-d24649e7e4d3403ad7888e64e8c277a81dd7ca97.zip
Initial import. Untested on real hardware.HEADmaster
Diffstat (limited to 'autopano1d.ino')
-rw-r--r--autopano1d.ino84
1 files changed, 84 insertions, 0 deletions
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 <ludovic@pouzenc.fr>
+ *
+ * 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 <https://www.gnu.org/licenses/>.
+ */
+// Tested on an Arduino Nano with IDE 1.8.5
+
+#include <Stepper.h>
+#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<pictureCount; i++ ) {
+ takePic();
+ rotate();
+ }
+}
+
+void takePic() {
+ SERIAL_TRACE;
+ // Draw current to ground for 50ms on shutterPin then return in high-Z state
+ digitalWrite(shutterPin, LOW);
+ pinMode(shutterPin, OUTPUT);
+ delay(50);
+ pinMode(shutterPin, INPUT);
+ // Wait for the pic
+ delay(cameraTakeDelay);
+}
+
+void rotate() {
+ SERIAL_TRACE;
+ myStepper.step(-cameraStepsPerRevolution/pictureCount);
+ delay(cameraStabilizeDelay);
+}
+