interfacing the digital camera with PIC 16f877

Thread Starter

computer woman

Joined Jan 28, 2012
hi everybody .....

can anyone help me to write the code for pic 16f877 to allow the webcam to capture the picture when specific condition achieved

i work on microbasic language .


Joined Sep 20, 2005
You mean a usb webcam?
16f877 doesn´t have USB, so you are so out of luck. Maybe if you hacked the cam and interfaced the picture chip directly it might be possible to do it, but then again the pic has only 384 bytes of RAM and 8KB program space, which is nowhere enough to do anything with a picture. I don´t know what microbasic is, but it probably won´t help either. To get anywhere with this chip you would need to write very optimised code in assembler and use external RAM.

I suggest you choose a different device that has at least a chance of doing what you want.


Joined Nov 25, 2011
Native USB is really hard to work and even harder if you don't have the datasheet for the USB interface of the camera.

Actually the camera is likely too fast while the memory card is too slow. The PIC isn't going to have enough buffer memory to bridge the two together. So with a slow, low memory PIC (and difficulty of working with USB) you aren't going to have much luck anyways making full use of the USB camera you do have. If you don't have the data-sheet for the USB protocol you don't really stand a chance at all.


Joined Jun 6, 2011
Sorry, guys. I read the OP a little differently.

It sounds like she want to trigger the cam upon when a particular condition arises. I assume the cam would be plugged to the PC, and the PIC would signal the cam to shoot.

If I am right, then its a simple matter to cobble an interface between the PIC and the shutter switch.

Or if I am wrong, well, then I am wrong...


Joined Feb 11, 2008
I'm pretty sure someone on the net did a "motion detect" project using a small camera and a PIC 16F.

From memory it only read some pixels on some lines (as the PIC is slow) but that was enough to check if pixels changed, ie; detect if someone walked in front of the camera.

Thread Starter

computer woman

Joined Jan 28, 2012
I prepared to security system in companies that work as follow:

Firstly, each employee have unique entrance code or password that typed on keypad
And the employee is allowed to enter his password 3 times at the maximum ( in case the employee write the password wrong or forget it)

Then if the employee write the password 3 times wrong then the camera ( that connected with circuit and the size of picture is 480X460 for example ) will take the picture for this employee and send it to the pc through ( RS-232) that connect with my circuit .

** to clarify more I want to connect the pic and camera and pc together on bredboard
, and I am not binding to using the webcam……( I understand the idea in general but still not know which appropriate h.w that I can use)

i hope that the project is clear now


Joined Oct 29, 2009
You are still not being clear on what you want the PIC to do.

Will the Pic be the part of the project that has the keyboard? If so then that is the easy part of the project.

Then you don't want the PIC to control the camera, you want the PC to control the camera.

Before going any further you need to have code on the PC that allows you to control the camera. Have you written this code and does it work?
Last edited:


Joined Jun 7, 2009
webcams don't generally capture a complete image. They transmit a data stream of image info. It's then up to the PC to buffer the info into a complete frame for storage.

You may just want to install a digital camera, complet with storage, and signal it to capture an image on some event. You could then read it via a USB interface, or simply remove/replace the storage.

Why not just continous overlap recording on a video cam, which is probably the most common installation.