Stap 3: Hoe te programmeren van de Galileo-Board:
Om te beginnen laden een van de volgende programma's met de Arduino IDE op uw Intel Galileo bord Gen 2.
De seriële Monitor geboden in de Arduino IDE zal feedback geven over de voortgang van de timelapse.
1. een eenvoudig programma voor een timelapse:
/*<br> Simple Timelapse: This program shoots a timelapse with the given parameters: shots, shutter and wait. With this setup the board will take 300 pictures with 0.5 seconds exposure every 2.5 seconds. The progress will be shown in the serial monitor. */ int shots = 300; // Number of pictures to be shot int shutter = 500; // Shutter speed (in ms) int wait = 2500; // Waiting time between the pictures (in ms) void setup() { pinMode(13, OUTPUT); // Set Pin 13 as output Serial.begin(9600); delay(5000); // Wait 5 seconds to get ready Serial.println("Starting Timelapse."); for (int i = 1; i <=shots; i++) { // Repeat shooting pictures until all shots are done shoot(); showProgress(i); delay(wait); } Serial.println("Timelapse complete."); } // Force the camera to take a picture with the given shutter speed void shoot() { digitalWrite(13, HIGH); delay(shutter); digitalWrite(13, LOW); } // Show progress on the Serial Monitor void showProgress(int i){ Serial.print("Pictures shot: "); Serial.print(i); Serial.print("/"); Serial.print(shots); Serial.print(", Time remaining: ca. "); // Evaluate the remaining time in minutes and seconds Serial.print((shots-i)*(shutter+wait)/60000); Serial.print("m "); Serial.print(((shots-i)*(shutter+wait)%60000)/1000); Serial.print("s\n"); } void loop() { delay(1000); }
2. een meer geavanceerde versie met wisselende blootstelling:
/*<br> Timelapse with changeing exposure. This program shoots a timelapse starting with the shutter speed given in shutterStart and then adapts the time every shoot until it reaches the time given in ShutterEnd. The progress will be shown in the serial monitor. */ int shots = 120; // Number of pictures int shutterStart = 500; // Shutter speed at the beginning of the timelapse(in ms) int shutterEnd = 2000; // Shutter speed at the end of the timelapse (in ms) int wait = 4000; // Waiting time between the pictures (in ms) void setup() { pinMode(13, OUTPUT); // Set pin 13 as output Serial.begin(9600); delay(5000); // Wait 5 seconds to get ready Serial.println("Taking initializing start picture."); //Sometimes the first picture has a wrong exposure, therefore take initializing picture shoot(1000); Serial.println("Done. Waiting for the camera."); delay(3000); //The camera needs some time to process the image Serial.println("Starting Timelapse."); for (int i = 1; i <=shots; i++) { shoot(shutterStart + (shutterEnd-shutterStart)*i/shots); // Adapt the exposure over time showProgress(i); delay(wait); } Serial.println("Timelapse complete."); } // Force the camera to takes a picture with shutter speed x void shoot(int x) { digitalWrite(13, HIGH); delay(x); digitalWrite(13, LOW); } // Show Progress on the Serial Monitor void showProgress(int i){ int shutter = (shutterStart + shutterEnd)/2; // Average shutter speed for time calculation Serial.print("Pictures shot: "); Serial.print(i); Serial.print("/"); Serial.print(shots); Serial.print(", Shutter: "); // Print current shutter speed: Serial.print(shutterStart + (shutterEnd-shutterStart)*i/shots); Serial.print("s, Time remaining: ca. "); // Evaluate the remaining time in minutes and seconds Serial.print((shots-i)*(shutter+wait)/60000); Serial.print("m "); Serial.print(((shots-i)*(shutter+wait)%60000)/1000); Serial.print("s\n"); } void loop() { delay(1000); }<br>
Het is natuurlijk mogelijk om deze programma's om speciale doelen zoals bijvoorbeeld een wachtende tijd veranderen over tijd of wat ooit gewenst is te bereiken.