I have a Raspberry PI 3B with an USB webcam attached.
With the fwebcam command I can take a photo and store in in a folder.
Now I want to use a push button to make a photo with the fswebcam command.
I've made a takepic.py script: (adapted from a script I found on the internet)
(There is some code to turn a led on and off, but I've chosen not to use an led, so that piece code can be deleted.
Also, the original script added a photo with a number. I want to overwrite the photo, so don't make use of the image_num +1)
Code: Select all
#!/usr/bin/env python
import sys, os, time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.IN) # push button (pin 11)
GPIO.setup(12, GPIO.OUT) # led (pin 12)
image_num = 1
GPIO.output(12, False)
while True:
if GPIO.input(11): # button is pushed
strImage = str(image_num)
"fswebcam --no-banner /var/www/html/webcam.jpg"
image_num = image_num + 1
GPIO.output(12, True) # led ON
time.sleep(3)
GPIO.output(12, False) # led OFF
GPIO.cleanup()
Also I've made an createpic.sh script and placed this into /etc/rc.local
Code: Select all
#! /bin/bash
python /home/pi/takepic.py &
1 wire go's to the GROUND on PIN6
1 wire go's to PIN11 (signal)
1 wire with a 10K resistor go's to the 3.3V on PIN1
Whatever I try, the script will not take a picture of the webcam.
Can anyone see what I'm doing wrong here ?