Raspberry Pi – Point & Shoot Camera

For my second real project for the Raspberry Pi I needed it to be something that took advantage of the recently released Raspberry Pi Camera Board. My idea was to make an extremely simple “point and shoot” camera. I wanted it to be able to run on batteries, connect over Wifi and have as much of the project inside of the original box as I could.

The connection to the button is done with a little proto-board from Radioshack (I like the ones with the square pads). It is basically using the schematic form this Adafruit tutorial on using buttons with the RPi. It just has a pullup resistor and a GPIO pin for each button you need. I just cut the RPi ribbon from Adafruit to make the attachment to the Raspberry Pi. I only have one button wired in, but you could do more or have LED indicator lights using the GPIO pins.

I will do more detailed instructions this weekend but to run this you will need to do the minimum:
Install Raspbian

Install Camera with raspi-config

Update Upgrade your Raspberry Pi

Install GPIO

Install FTP (for external access to images, not required)

Run Camera.py
The Python file that is just loops waiting looking for a button press, the simple file is here (as a google drive file for save viewing):
(the simple camera version, with no display)

I also made an updated version that uses a TFT screen and displays each picture after it is taken. The Updated version is available on GitHub here:
(requires that PyGame is installed on the RPi)

It needs to be running in order for the camera to fire, so you may need to have your Pi boot right into it.

The final piece was making the ultra tiny USB cable using a slice from normal sized cable and some careful soldering and glue gun usage. This way it locks in nicely and the Enercell battery lasts about 3.5 hours.

Parts needed for this Project:

Raspberry Pi – $35

Raspberry Pi – Camera Board – $25

Case for the RPi – ~$10

Ribbon Cable – $3

Button Board and button from Radioshack -$10

Not required but extremely helpful when learning the Raspberry Pi:
Getting started with the Raspberry Pi – by Matt Richardson ($12)

Button Shield using GPIO and Ribbon Cable

This is a ribbon cable that was cut and systematically wired into the proto-board. I wired in all the pins even though in this case I am only using a few. This was because in the future I may want to add additional buttons or use other pins and this sort of setup means that the project can grow without having to start from scratch.

NOTE: You can see that I actually have 2 pull-up resistors wired to pins 23 and 24, but I am only using GPIO pin 24 right now but pin 23 is ready for an additional button as is. I was thinking of adding the second button for taking a video but have not yet had a chance to work that out.

The way that the pins need to be wired to the Raspberry Pi is like this:

(from the Adafruit example on wiring buttons to the RPi here)

Then you can test to see if they are pressed in python like this:


This line of code looks to see if the GPIO pin 24 is currently grounded (i.e. pressed), The pull-up resistor prevents this pin from appearing grounded unless the button has been pressed.

Mini USB cable

The USB cable can be easily made by cutting and shortenting any USB micro cable or done by purchasing these components from adafruit:
but if you buy these make sure that the wire you are using is thick enough to carry the current needed to power the RPi (my first attempt failed because I was using very small ribbon cable).

Autostart the camera.py file

Another thing I needed in case I had to switch batteries without connecting back to a screen was to make sure that it started the application on every boot. To do that I added a single line of code to the LXDE autostart file. I chose this file instead of a few other options because I wanted it to boot into LXDE and run the application in a terminal window from there so that I could see the button presses on the desktop. The file I edited is here:

and the additional command I placed at the end of the autostart file was this:
@lxterminal -e “sudo python /home/pi/camera/camera.py”
This basically starts an LXTerminal window and asks it to execute the command that starts the camera.py application

More Pics of the Camera

If you want to see the kinds of photos that can be taken on the RPI I put and album up showing a set of pictures I captured after making the first version of the Camera. That Album is here (ignore the first pic, that was the older prototype):


Next Steps: The Screen

Right now I am working on getting the screen (image above) working using just the 5v power from the Raspberry Pi GPIO header. To do this I plan on using a buck booster to convert the 5v to a 9v to keep in the 6-15v required by the screen. I may see if I can lower the voltage to 6v or see what the minimum the screen will work at in order to keep power waste to a minimum.

51 Responses to Raspberry Pi – Point & Shoot Camera

  1. Awesome keep up the ROCKSTAR work!

  2. Pingback: Community Corner: Projects Shared By Adafruit Industries - Limor Fried and Dozens More « adafruit industries blog

  3. Pingback: Raspberry Pi Point & Shoot Camera #piday #raspberrypi @Raspberry_Pi « adafruit industries blog

  4. Awesome stuff. Great project. Going to re-blog it.

  5. Pingback: Point & Shoot Camera with the #RaspberryPi | Raspberry PiPod

  6. Pingback: Community Corner: Pre-Programmed Arduino Light Show and More from This Week in Adafruit’s Community « adafruit industries blog

  7. Georgian says:

    Hi, Very nice job. thanks for sharing this. I have a question, why is the camera taking a picture every second (without any GPIO connected), but if i press the button the camera stops taking pictures. I mention that i have model B rev 1 board with latest raspbian. many thanks in advance, Georgian.

    • Georgian, sounds like you have the GPIO pins not wired correctly, can you post a link to a pic of how you have it connected? the button press should ground the pin, and it needs a pull-up resistor to power. Take another look at my diagram and send me a pic to look at. Sounds like the GPIO is wired in reverse because pressing the button does the opposite of what you need it to do.

      • Georgian says:



        Thanks for answer, I took the best quality pics i could. Look like all the wires are correctly. I have to mention that some time ago I done something similar ( internet radio with 20*4 LCD) and it acted the same, I solved the problem by changing “if(GPIO.input(24)==True):” with “if(GPIO.input(24)==False):” and worked fine after. But in this code it is already “False”. I’m not using any program that is using the GPIO port, so i don’t think it they are already used by other program. Thanks for help and sorry for my bad english.

      • Use a voltmeter to check your circuit. It looks right from here but maybe the button is reversed (i.e. a button that opens when pressed as apposed to closes?). Make sure that your green wire is delivering the proper voltage and that even through the resistor has some (albeit small) voltage. Make a program that just outputs the value of the pin 24 and play around with it (attach is straight to ground), but DO NOT ATTACH PIN 24 STRAIGHT TO THE 5v pin, only through the resistor (its not able to handle 5v input). Also make sure you look at the pinouts for the version of the RPi that you have, there are some small differences in the versions as I have seen, mine is one of the older RPi’s so keep that in mind. Let me know what you find out. Post the version of the RPi and a link to the Pinout diagram you are using.

  8. Georgian says:

    Hi, first i want to thanks you for all your support. Thanks!
    I solved the problem by replacing the push button (for some reason sometimes was stuck to close position, weird. I throw it in rubbish straight away). now i got a decent push button and soldered wires to it. inside the shrink tube is the resistor and the other two wires and also the GND. Now i can’t wait to get box for it and make a self shoot in the mirror :)).
    Many thanks again for this great project. Georgian


    • Georgian,
      EXCELLENT! I thought it might have been something weird like that. Glad to hear you were able to properly test it and figure out where the problem was (and remove it). Looks good, smart idea placing the button hidden away in the shrink tube. I posted a new video (top of this page) that shows mine with the Adafruit display screen. Also if you use google+ I am here:


      I post regularly about my projects and other fun electronics.
      Glad my project helped.

  9. Pingback: Make a Point and Shoot Camera with a Raspberry Pi | qazwilson

  10. Pingback: Make a Point and Shoot Camera with a Raspberry Pi | Binary Reveux

  11. Pingback: Make A Point-And-Shoot Camera With A Raspberry Pi | Lifehacker Australia

  12. Cyb3 says:

    Nice done man. I will bookmark your blog!

  13. Fantastic project – I’ve been looking for a way of taking pictures with a GPIO input for my Holga Pi – Raspberry Pi fitted into a medium format camera – project – details here: http://kimondo.co.uk/holga-120-d/ I have found a supply of really slim usb cables which helps a lot with fitting things into the case.

    • Nice Holga Pi project! You know it wasn’t too hard to get the screen working with the Raspberry Pi (through the vga). Adafruit has it in a few different sizes. You could install it in your project pretty easily. I took a working USB cable and cut just the ends into a super short USB cable.

  14. Pingback: Aparat foto cu Raspberry PI | Robofun Blog

  15. Do you think that this display:


    Would work for a project like this?
    I’m pretty good with Linux, very good with soldering and circuits, not that great at proramming… I’m about to receive a Raspberry Pi with the camera in a few days and am very excited at the idea of building a digital camera. Just wanted to know what you opinion of a display like this, not exactly mainstream from what I can gather. Anyway, thanks!

  16. m005kennedy says:

    Now all you have to do is add a GPS to embed the location data in the photo file! excellent work!

  17. Pingback: Make a $126 digital camera with touchscreen using Raspberry Pi | Digital Trends

  18. Pingback: DIY一个带WIFI的树莓派照相机 | Boyd Wang

  19. Tony Stark says:

    Wow that’s AWESOME!! I’m really impressed with the quality of the photos too, having had a flick through your album on G+.
    I’ve only just received my Pi (a Christmas present from my wonderful GF <3) and after discovering the camera add-on(s) and the various TFT add-ons the first though I had was a custom "point-n-shoot" camera combined inside a typical hand-held sized case so I'm REALLY impressed with your work.
    I look forward to seeing your progress with the TFT screen addition and perhaps braving a go myself one of these fine days! :D

  20. ahmed says:

    very nice and awesome project . i have been looking for this project and i got from your website.. thank you pal, but i have a doubt when i run the code in python it show an error as UNEXPECTED INDENT near (DEF TAKEPIC) , can you just help me out wit that and sorry for my bad english.
    thank you

    • Ahmed, no worries, that is probably because Python pays special attention to indenting. You may have made an error in how you copied and pasted the code in. Make sure you double check all the indenting in the code you are using. If you have some indenting that doesn’t make sense to the compiler, it will give you that error. Just read through your code, I am sure you will be able to find it.

  21. ahmed says:

    ya i cross checked the code more than 3 times and then i posted was unable to resolve it so.i have installed python and also gpio too but don’t know why it is showing that..

    • Ahmed, that is a compile time error. If it is saying that there must be something off from your indentations, start by pulling the later parts of the code out and seeing if you can get it to stop saying that, then add them back in one block at a time (a “block” is identified by code that is run sequentially and is indicated by being indented together).

    • Also, maybe copy and paste the code into a new file so that the Google Doc formatting doesn’t mess up the indenting.

  22. bhoobalan says:

    hi awesome project loved it and am trying it too.actually am new to this RAspberry Pi so having a doubt how can i get back to desktop if i want after that camera screen comes when power is on..

    • bhoobalan, ok good question. Like most python scripts a hitting “Control-C” will kill it and take you right back to the OS.

      • bhoobalan says:

        Am sorry, am not getting it out. i pressed that ‘control c’ even after that also not coming.. is there any other option.
        thank you

  23. bhoobalan, I think I forgot that I needed to put a check for that, try to add this in the first part of the while loop like this:

    for event in pygame.event.get():
    if event.type == pygame.QUIT: sys.exit()

    I updated it in the code, thanks for pointing it out. Let me know if this solves it for you.

  24. Pingback: Crea tu propia camara a base de un Raspberry Pi | LiGNUx

  25. Pingback: DIY WiFi Raspberry Pi Touchscreen Camera | Developer's blog

  26. Pingback: Podcast 123 – My posture picture | 64

  27. Pingback: DIY一个带WIFI的树莓派照相机 - 极客范 - GeekFan.net

  28. Pingback: Point & Shoot Camera Built With Raspberry Pi - DIY Photography

  29. hi sir i got error in below

    pygame.error: video system not initialized

    pls help me


    • james wolf says:

      Suryakant, can you send me the full error? are you using my code exactly?

      • hi sir got below error

        pi@raspberrypi ~ $ sudo python camera.py
        Raspberry Pi Camera with Buttons
        Traceback (most recent call last):
        File “camera.py”, line 94, in
        for event in pygame.event.get():
        pygame.error: video system not initialized

        pls help me


      • james wolf says:

        Suryakant, check you code for me, does line 94 look EXACTLY like this:

        for event in pygame.event.get():
        if event.type == pygame.QUIT: sys.exit()

        make sure it says pygame.QUIT and NOT pygame.quit()
        (I had that issue in my original posted code and saw that described when I googled your error)

        also, which version of Python are you running?

  30. CRImier says:

    This sure is a great project! I think I’ll be able to take some info from your work while working on my wearable Raspberry Pi project. I just think one wouldn’t need any desktop environment – I think that for the screen you can just use framebuffer (http://en.wikipedia.org/wiki/Linux_framebuffer). There must be a tutorial for working with framebuffer from Python somewhere out there, and I guess I’ll make one as I’ll work on it.

  31. Pingback: Lista della spesa – Pi Camera – TGLabs

  32. Justin says:

    Mind if I ask what the build time for this project was?

    • james wolf says:

      The total build time if you had all the parts together and the SD card already with Debian installed is around 3-4 hours, depending on your ability to solder and install libraries on Linux. Everything you need is here in the instructions, let me know if you have any questions about the steps.

  33. Pingback: 3 Raspberry Pi Camera Projects | Initial StateInitial State |

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s