Sunday, October 19, 2014

Next intermediate Project:

Programmable Samsung NX300M remote.

After i testet a EOS M and sent it back because it wasn't very ergonomic i bought a Samsung NX300M. Not only has this camera a Wifi Viewfinder, but it also has a USB Remoteshutter, which is only 2 shorts between ground and Data+ and Data- and a 68K resistor. Here is whar i came up with in Fritzing (cool program to document breadboard-ciruits)

Here is the shoppinc-chart for the circuit:
  • Arduino Pro Mini
  • 2 tactile switches
  • 5 LEDs (i had some orange ones)
  • 2 Optocoupplers (i had some SFH611-2 lying around)
  • some resistors
  • 2 coincells and mounts
  • 1 mini-switch
  • 1 housing fitting in my hand
  • 1 micro-USB plug
This is the source code i hacked together. Some parts are from the arduino examples.


 /* LEDs are on Pins 12,11,10,9,8
Optos on pin 4 (shuter) and 5 (Fokus)

tactile switches on 2 (mode-switch) and 3 (shutter)
Mode 0 = only shutter
Mode 1 = endless with 0.5 sec delay
Mode 2 = same but 1 sec delay
Mode 3 = 5 sec delay
Mode 4 = 20 sec delay
*/


const int selectPin = 2;    // the number of the pushbutton pin
const int shutterPin = 3;    // the number of the pushbutton pin
int modus=0;
long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers
int pinArray[] = {12, 11, 10, 9, 8,4,5};
int count = 0;
int buttonState;             // the current reading from the input pin
int lastButtonState = HIGH;   // the previous reading from the input pin
int warten=500;
//
void setup() {
// put your setup code here, to run once:
pinMode(selectPin, INPUT);
for (count=0;count<7;count++) {
pinMode(pinArray[count], OUTPUT);
}
// set initial LED state
//
for (count=0;count<5;count++) {
if ( count == modus )
{
digitalWrite(pinArray[count], HIGH);
}
else
{
digitalWrite(pinArray[count], LOW);
}
}
modus++;
//
//Shuter
digitalWrite(pinArray[5],LOW);
digitalWrite(pinArray[6],LOW);
}
//
void shoot (int shootmode) {
//shootonce
if ( shootmode ==0)
{
digitalWrite(5,HIGH);
delay (50);
digitalWrite(4,HIGH);
delay(100);
digitalWrite(4,LOW);
delay(50);
digitalWrite(5,LOW);
}
else
{
switch (shootmode) {
case 1:
warten=500;
break;
case 2:
warten=1000;
break;
case 3:
warten=5000;
break;
case 4:
warten=20000;
break;
}
while (true)
{
digitalWrite(5,HIGH);
delay (50);
digitalWrite(4,HIGH);
delay(100);
digitalWrite(4,LOW);
delay(50);
digitalWrite(5,LOW);
delay(warten);
}
}
//debounce
delay (100);
}
void loop() {
// put your main code here, to run repeatedly:
int reading = digitalRead(selectPin);
int shutter = digitalRead(shutterPin);
if (reading != lastButtonState) {
// reset the debouncing timer
lastDebounceTime = millis();
}
//
if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
// if the button state has changed:
if (reading != buttonState) {
buttonState = reading;
// only toggle the LED if the new button state is HIGH
if (buttonState == LOW) {
for (count=0;count<5;count++) {
if ( count == modus )
{
digitalWrite(pinArray[count], HIGH);
}
else
{
digitalWrite(pinArray[count], LOW);
}
}
modus++;
if (modus >4 ) {
modus =0;
}
}
}
}
lastButtonState = reading;
if (shutter = LOW)
{
shoot (modus);
}


Some things i have figured out while writing the code. This is stil a prototype, but i think i have to put the LED off when entering the endless loop. This will 1st save battery and 2nd the light will influence a long exposure.