SungWoon Lee
Published © GPL3+

Wireless Camera Shutter Release DIY

Wireless camera shutter release example with PHPoC Blue.

BeginnerShowcase (no instructions)8 hours979
Wireless Camera Shutter Release DIY

Things used in this project

Hardware components

PHPoC Blue
PHPoC Blue
×1
PHPoC Bread Board
PHPoC Bread Board
×1
CATALEX Dual Relay [S1-09]
×1
2.5mm stereo plug to 3.5mm stereo socket adapter
×1
3.5mm stereo plug
×1
EOS-400D
×1

Story

Read more

Schematics

schemetics

Code

task0.php

PHP
<?php 

if(_SERVER("REQUEST_METHOD"))
    exit; // avoid php execution via http request

include_once "/lib/sd_340.php";
include_once "/lib/sn_tcp_ws.php";

define("FOCUS_PIN", 1);
define("SHUTTER_PIN", 0);

uio_setup(0, FOCUS_PIN, "out low");
uio_setup(0, SHUTTER_PIN, "out low");
ws_setup(0, "release", "csv.phpoc");

$rwbuf = "";

while(1)
{
    if(ws_state(0) == TCP_CONNECTED)
    {
        $rlen = ws_read_line(0, $rwbuf);

        if($rlen)
        {
            uio_out(0, FOCUS_PIN, (int)$rwbuf);
            if((int)$rwbuf == 0)
            {
                uio_out(0, SHUTTER_PIN, HIGH);
                usleep(100000);
                uio_out(0, SHUTTER_PIN, LOW);
            }
        }
    }
}

?>

index.php

HTML
<!DOCTYPE html>
<html>
<head>
<title>PHPoC / <?echo system("uname -i")?></title>
<meta name="viewport" content="width=device-width, initial-scale=0.7">
<style> body { text-align: center; } </style>
<script>
var canvas_width = 95;
var canvas_height = 95;
var ws;
function init()
{
    var button = document.getElementById("button");

    button.width = canvas_width;
    button.height = canvas_height;

    button.addEventListener("touchstart", mouse_down);
    button.addEventListener("touchend", mouse_up);
    button.addEventListener("mousedown", mouse_down);
    button.addEventListener("mouseup", mouse_up);
    button.addEventListener("mouseout", mouse_up);

    update_button(0);

    ws = new WebSocket("ws://<?echo _SERVER("HTTP_HOST")?>/release", "csv.phpoc");
    document.getElementById("ws_state").innerHTML = "CONNECTING";

    ws.onopen  = function(){ document.getElementById("ws_state").innerHTML = "OPEN" };
    ws.onclose = function(){ document.getElementById("ws_state").innerHTML = "CLOSED"};
    ws.onerror = function(){ alert("websocket error " + this.url) };

    ws.onmessage = ws_onmessage;
}
function ws_onmessage(e_msg)
{
    e_msg = e_msg || window.event; // MessageEvent

    alert("msg : " + e_msg.data);
}
function update_button(state)
{
    var button = document.getElementById("button");

    if(state)
        button.style.backgroundImage = "url('/button_push.png')";
    else
        button.style.backgroundImage = "url('/button_pop.png')";
}
function mouse_down()
{
    if(ws.readyState == 1)
        ws.send("1\r\n");

    update_button(1);

    event.preventDefault();
}
function mouse_up()
{
    if(ws.readyState == 1)
        ws.send("0\r\n");

    update_button(0);
}
window.onload = init;
</script>
</head>
<body>

<h2>
UIO / Camera Release<br>

<br>

<canvas id="button"></canvas>

<p>
WebSocket : <span id="ws_state">CLOSED</span><br>
</p>

</h2>

</body>
</html>

Credits

SungWoon Lee

SungWoon Lee

1 project • 4 followers

Comments