Last active
August 29, 2015 14:10
-
-
Save daniel-j/4ec9dd6f10fa287b55ed to your computer and use it in GitHub Desktop.
Take a photo with a system camera using a button connected to GPIO!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger-camera |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
gcc -o trigger-camera main.c -lwiringPi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <wiringPi.h> | |
#define TRIGGER_PIN 9 | |
void setup() { | |
if (wiringPiSetup () == -1) { | |
exit (1); | |
} | |
printf ("Setup... \n"); | |
printf("Button pin: %d\n", TRIGGER_PIN); | |
pinMode(TRIGGER_PIN, INPUT); | |
} | |
void waitButton (void) { | |
printf ("Waiting for button press...\n"); | |
while (digitalRead(TRIGGER_PIN) == HIGH) { | |
delay (50); | |
} | |
printf ("Button pressed!\n"); | |
} | |
void takePhoto() { | |
printf("Taking photo...\n"); | |
system("./takephoto.sh"); | |
printf("Photo captured!\n"); | |
} | |
int main (void) { | |
setup(); | |
for(;;) { | |
waitButton(); | |
//delay(1000); | |
takePhoto(); | |
//delay(1000); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#TIMESTAMP=$(date +"%m-%d-%Y") | |
DATE=`date +"%Y-%m-%d"` | |
TIME=`date +"%H-%M-%S"` | |
ROOT=/julfest/bilder | |
mkdir -p $ROOT/$DATE/ | |
FILENAME="$ROOT/$DATE/julfest $DATE $TIME.jpg" | |
gphoto2 --auto-detect --capture-image --get-all-files --filename="$FILENAME" | |
chown djazz:users "$FILENAME" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Trigger Camera Service | |
Requires=network.target local-fs.target | |
[Service] | |
Type=forking | |
KillMode=none | |
ExecStart=/usr/bin/tmux new-session -d -P -s trigger-camera -n trigger-camera ./trigger-camera | |
ExecStop=/usr/bin/tmux send-keys -t trigger-camera:trigger-camera C-c | |
WorkingDirectory=/path/to/trigger-camera/ | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment