Difference between revisions of "Time-lapse Photography"

From Microduino Wiki
Jump to: navigation, search
(Software Debugging软件调试)
 
(13 intermediate revisions by 4 users not shown)
Line 3: Line 3:
 
|-
 
|-
 
|
 
|
==Objective ==
+
==Objective==
Use the key to set the time delay and take pictures with SONY camera after the setting.
+
Here we use the Microduino-IR Emitter to send infrared signal in the delayed time so as to control a SONY camera for picture taking and achieve time-lapse photography. 
 +
==Experiment One: System sends signal in the delayed time ==
 +
===Equipment===
 +
{|class="wikitable"
 +
|-
 +
|Module||Number||Function
 +
|-
 +
|[[mCookie-CoreUSB]]||1||Core board
 +
|-
 +
|[[mCookie-Hub]]||1||Sensor pin board
 +
|-
 +
| [[Microduino-IR Emitter]]||1||Infrared emission sensor
 +
|}
 +
 
 +
===Preparation===
 +
*Setup 1: Connect the interface of the IR-Emitter to the D6 port of the Hub. (Note: The pin connection cannot be changed.)
 +
[[file:mCookie-IR transmitter-sensor.JPG|600px|center]]
 +
*Setup 2: Stack the CoreUSB, Hub and IR-Emitter together and them connect them to a computer with a USB cable.
 +
[[file:mCookie-IR transmitter-pc.JPG|600px|center]]
 +
 
 +
===Debugging===
 +
*Open Arduino IDE and copy the following code into IDE. 
 +
<source lang="cpp">
 +
#include <IRremote.h>
  
==Principle==
+
#define PHOTO 0xB4B8F
Here we can set the time delay by detecting how many times you press the key and use the infrared transmission sensor to control SONY camera.
 
  
==Equipment ==
+
IRsend irsend;
 +
 
 +
 
 +
void setup() {
 +
  Serial.begin(115200);
 +
  pinMode(6, OUTPUT);
 +
}
 +
 
 +
void loop() {
 +
  for (int i = 0; i < 3; i++)
 +
  {
 +
    irsend.sendSony(PHOTO, 20); // Sony code
 +
    delay(12);
 +
  }
 +
  delay(5000);
 +
}
 +
</source>
 +
*Select the right board and COM port, compile and download directly. 
 +
[[file:upload.JPG|400px|center]]
 +
*Turn on the camera and change to remote control mode. 
 +
[[file:sony-photo.JPG|400px|center]]
 +
*Aim the IR Emitter to the camera and send signal every 5s. You can see the LED indicator on the IR Emitter flashes and hear the picture-taking sound at the same time.
 +
*It's wonderful to make the time-lapse pictures into GIF.
 +
[[file:gif-photo.gif|400px|center]]
 +
 
 +
===Program Debugging===
 +
*Adopt " IRremote " infrared library to support the sending and receiving of the infrared signals.
 +
*"#define PHOTO 0xB4B8F" Define this SONY camera's infrared signal value.
 +
*Change the delay time;  "delay(5000)" means five seconds.
 +
==Experiment Two: Key Control Picture-taking ==
 +
===Equipment===
 
{|class="wikitable"
 
{|class="wikitable"
 
|-
 
|-
 
|Module||Number||Function
 
|Module||Number||Function
 
|-
 
|-
|[[Microduino-CoreUSB]]||1||Core board
+
|[[mCookie-CoreUSB]]||1||Core board  
 
|-
 
|-
|[[Microduino-Sensorhub]]||1||Sensor pin board
+
|[[mCookie-Hub]]||1||Sensor pinboard
 
|-
 
|-
| [[Microduino-IR transmitter]]||1||Infrared transmission sensor  
+
| [[Microduino-IR Emitter]]||1||Infrared emission sensor
 
|-
 
|-
| [[Microduino-Crash]]||1||Crash sensor  
+
| [[Microduino-Crash]]||1||Crash sensor
 
|}
 
|}
 +
 
  [[File:IR_Crash.jpg|600px|center|thumb]]
 
  [[File:IR_Crash.jpg|600px|center|thumb]]
  
 +
===Hardware Buildup===
 +
*Setup 1: Connect the IR-Emitter to the Hub D6 and the Crash sensor to the Hub D8.
 +
[[file:mCookie-IR transmitter-pc.JPG|600px|center]]
 +
*Setup 2: Stack the CoreUSB, Hub, Crash and IR-Emitter together and them connect them to a computer with a USB cable.
 +
[[file:mCookie-IR transmitter-crash-pc.JPG|600px|center]]
  
==Hardware Buildup ==
+
===Software Debugging===
*Setup 1:Stack CoreUSB and Sensorhub together.。
+
* Open Arduino IDE and copy the following code into IDE.
[[File:CoreUSB_Sensorhub.jpg|600px|center|thumb]]
+
<source lang="cpp">
*Setup 2:Connect the infrared transmitter to the D8 pin of Sensorhub and the crash sensor to the D2 pin of Sensorhub.  
+
#include <IRremote.h>
[[file:Microduino-sensorhub_rule.JPG|thumb|800px|center]]
 
[[File:ir_transmitter.jpg|600px|center|thumb]]
 
  
==Software Debugging==
+
#define PHOTO 0xB4B8F
*Infrared remote control encoding definition. Here we adopt SONY encoding format.
+
 
<source lang="cpp">
+
IRsend irsend;
  
#define PHOTO 0xB4B8F    //SONY camera ending
+
#define pushButton  8
#define KEY 2            //Key interface
 
  
boolean keyFlag = false;  //Key flag 
+
int buttonState, num;
unsigned long timeFlag = 0;  //Time flag
 
int delayTime = 0;
 
  
IRsend irsend;
+
void setup() {
</source>
+
  Serial.begin(115200);
[[File:Microduino_photo_ir.png||300px|center|thumb]]
+
  pinMode(6, OUTPUT);
*Judge how many time you press the key. If you can't detect the next press-down within one second of the last press-down, it means you've finished pressing down. Then, after delaying for a certain period of time, it'll send photo encoding and control the camera to take photos.
+
  pinMode(pushButton, INPUT);
 +
}
  
<source lang="cpp">
+
void loop() {
   if((millis()> timeFlag+1000)&&delayTime>0)     // Judge how many time you press the key. If you can't detect the next press-down within one second of the last press-down, it means you've finished pressing down.
+
  buttonState = digitalRead(pushButton);
 +
   if (num != buttonState)
 
   {
 
   {
     delay(delayTime*1000);                     //Set the delay time according to how many times you press down.
+
     num = buttonState;
 
+
     if (num == 0)
     for (int i = 0; i < 3; i++)  
 
 
     {
 
     {
       irsend.sendSony(PHOTO, 20);               //Send photographing instruction
+
       take();
       delay(10);
+
       Serial.println("take");
 
     }
 
     }
    Serial.println("take photo");
 
    delayTime = 0;
 
 
   }
 
   }
 
+
}
   if(keyFlag==false && digitalRead(KEY)==LOW)   //Judge if the key is pressed down.
+
 
 +
void take()
 +
{
 +
   for (int i = 0; i < 3; i++)
 
   {
 
   {
     keyFlag = true;
+
     irsend.sendSony(PHOTO, 20); // Sony code
 +
    delay(12);
 
   }
 
   }
  else if(keyFlag==true && digitalRead(KEY)==HIGH)   //Judge if the key is released.
+
}
 +
</source>
 +
 
 +
*Result:
 +
You can target the IR Emitter to the camera's infrared receiver, then set the camera to remote control mode, press the key and button and the camera takes picture once.
 +
===Program Description ===
 +
*When pressing, the status is changed from "1" to "0". Conversely, the status changes from "0" to "1" when releasing the button. You can tell the status from the data change.
 +
<source lang="cpp">
 +
buttonState = digitalRead(pushButton);
 +
  if (num != buttonState)
 
   {
 
   {
     delayTime++;                           //The time of pressing the key+1
+
     num = buttonState;
     timeFlag = millis();
+
     if (num == 0)
     keyFlag=false;
+
    {
 +
      take();
 +
      Serial.println("take");
 +
     }
 
   }
 
   }
  delay(100);
 
 
</source>
 
</source>
 
+
*"!=" means "Not equal to", which only performs when the pressed value changes.
==Program==
 
[[https://github.com/Microduino/Microduino_Tutorials/tree/master/MCookie_Tutorial/MicroduinoDelayPhoto MicroduinoDelayPhoto]]
 
 
 
==Result==
 
Align the infrared transmission sensor to the infrared receiving head of the camera, set remote control mode, press the key for several times and then take pictures after a while.
 
  
 
==Video==
 
==Video==
  
 
|}
 
|}

Latest revision as of 23:37, 8 March 2017

Language: English  • 中文

Objective

Here we use the Microduino-IR Emitter to send infrared signal in the delayed time so as to control a SONY camera for picture taking and achieve time-lapse photography.

Experiment One: System sends signal in the delayed time

Equipment

Module Number Function
mCookie-CoreUSB 1 Core board
mCookie-Hub 1 Sensor pin board
Microduino-IR Emitter 1 Infrared emission sensor

Preparation

  • Setup 1: Connect the interface of the IR-Emitter to the D6 port of the Hub. (Note: The pin connection cannot be changed.)
  • Setup 2: Stack the CoreUSB, Hub and IR-Emitter together and them connect them to a computer with a USB cable.

Debugging

  • Open Arduino IDE and copy the following code into IDE.
#include <IRremote.h>

#define PHOTO 0xB4B8F

IRsend irsend;


void setup() {
  Serial.begin(115200);
  pinMode(6, OUTPUT);
}

void loop() {
  for (int i = 0; i < 3; i++)
  {
    irsend.sendSony(PHOTO, 20); // Sony code
    delay(12);
  }
  delay(5000);
}
  • Select the right board and COM port, compile and download directly.
Upload.JPG
  • Turn on the camera and change to remote control mode.
  • Aim the IR Emitter to the camera and send signal every 5s. You can see the LED indicator on the IR Emitter flashes and hear the picture-taking sound at the same time.
  • It's wonderful to make the time-lapse pictures into GIF.

Program Debugging

  • Adopt " IRremote " infrared library to support the sending and receiving of the infrared signals.
  • "#define PHOTO 0xB4B8F" Define this SONY camera's infrared signal value.
  • Change the delay time; "delay(5000)" means five seconds.

Experiment Two: Key Control Picture-taking

Equipment

Module Number Function
mCookie-CoreUSB 1 Core board
mCookie-Hub 1 Sensor pinboard
Microduino-IR Emitter 1 Infrared emission sensor
Microduino-Crash 1 Crash sensor

Hardware Buildup

  • Setup 1: Connect the IR-Emitter to the Hub D6 and the Crash sensor to the Hub D8.
  • Setup 2: Stack the CoreUSB, Hub, Crash and IR-Emitter together and them connect them to a computer with a USB cable.

Software Debugging

  • Open Arduino IDE and copy the following code into IDE.
#include <IRremote.h>

#define PHOTO 0xB4B8F

IRsend irsend;

#define pushButton  8

int buttonState, num;

void setup() {
  Serial.begin(115200);
  pinMode(6, OUTPUT);
  pinMode(pushButton, INPUT);
}

void loop() {
  buttonState = digitalRead(pushButton);
  if (num != buttonState)
  {
    num = buttonState;
    if (num == 0)
    {
      take();
      Serial.println("take");
    }
  }
}

void take()
{
  for (int i = 0; i < 3; i++)
  {
    irsend.sendSony(PHOTO, 20); // Sony code
    delay(12);
  }
}
  • Result:

You can target the IR Emitter to the camera's infrared receiver, then set the camera to remote control mode, press the key and button and the camera takes picture once.

Program Description

  • When pressing, the status is changed from "1" to "0". Conversely, the status changes from "0" to "1" when releasing the button. You can tell the status from the data change.
buttonState = digitalRead(pushButton);
  if (num != buttonState)
  {
    num = buttonState;
    if (num == 0)
    {
      take();
      Serial.println("take");
    }
  }
  • "!=" means "Not equal to", which only performs when the pressed value changes.

Video