I know that there is a lot on the Internet ( http://forum.arduino.cc/index.php?topic=159557.0 ) about OV7670, and I read a lot about it, but it seems that something is missing.
First of all, I looked at how we can read pixel pixels from a camera to create a rectangular image of 600 X 480, and this was pretty easy to understand, given that HREF, VSYNCH and PCLOCK are described here in the documentation: http: // www. voti.nl/docs/OV7670.pdf . I understand that XCLOCK as input I need to give OV7670 as a kind of loop controller, and RESET is something like RESET it.
So, at this moment I thought that the functionality of such a camera would be covered by the wiring of the following contacts:
- D0..D7 - for data (pixels) connected to arduino digital pins from 0 to 7, like INPUT on an arduino board.
- XCLK - for camera clocks connected to arduino digital output 8, like OUTPUT from an arduino board.
- PCLK - for pixel clocks connected to arduino digital pin 9, like INPUT on an arduino board.
- HREF - determine when the line starts / ends, connected to the arduino digital output 10, as INPUT on the arduino board.
- VSYCH - determine when the frame starts / ends, connects to the arduino digital output 11 as INPUT on the arduino board.
- GRD - groud connected to arduino GRD
- 3V3 - 3.3 INPUT connected to arduino 3.3v
- RESET - connected to arduino RESET
- PWDN - connected to arduino GRD
The implementation of this approach from my point of view will be something like this: Code:
for each loop function do write high to XCLK if VSYNCH is HIGH return; if HREF is LOW return; if lastPCLOCK was HIGH and currentPCLOCK is LOW readPixelFromDataPins(); end for
My readPixelFromDataPins() basically reads only the first byte (since I'm just testing if I can even read something from the camera), and it is written as follows:
the code:
byte readPixelFromDataPins() { byte result = 0; for (int i = 0; i < 8; i++) { result = result << 1 | digitalRead(data_p[i]); } return result; }
To check that something is being read from the camera, I just print it on the Serial 9600, the byte is read from the data contacts as a number. But at the moment I am only getting null values. The code I use to get the image is stored here: https://gist.github.com/franciscospaeth/8503747 .
Does someone who makes an OV7670 work with Arduino already figure out what I'm doing wrong? I suppose I'm using XCLOCK incorrectly? What should I do to make it work?
I searched a lot and I did not find any SSCCE ( http://sscce.org/ ) for this camera using arduino, if anyone has it please let me know.
This question is present on the arduino forum ( http://forum.arduino.cc/index.php?topic=211741.0 ).
camera clock arduino
Francisco spaeth
source share