Last active
December 29, 2018 20:21
-
-
Save franciscospaeth/8503747 to your computer and use it in GitHub Desktop.
OV7670 Snapshot Test Code
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
| // pin definition | |
| int data_p[] = {0,1,2,3,4,5,6,7}; | |
| int xclock_p = 8; | |
| int pclock_p = 9; | |
| int href_p = 10; | |
| int vsynch_p = 11; | |
| // not used int siod = 12; | |
| // not used int sioc = 13; | |
| int lastPclock = 0; | |
| int pclock; | |
| int href; | |
| int vsynch; | |
| byte pixel; | |
| void setup() { | |
| Serial.begin(9600); | |
| Serial.println("started"); | |
| // configure data pins as input | |
| for (int i = 0; i < 8; i++) { | |
| pinMode(data_p[i], INPUT); | |
| } | |
| // configure rest input pins | |
| pinMode(xclock_p, OUTPUT); | |
| pinMode(pclock_p, INPUT); | |
| pinMode(href_p, INPUT); | |
| pinMode(vsynch_p, INPUT); | |
| } | |
| int control = 0; | |
| void loop() { | |
| // just take one snapshot (307200 = 600 * 480) {{{ | |
| if (control >= 307200) { | |
| return; | |
| } | |
| // }}} | |
| digitalWrite(xclock_p, HIGH); | |
| //Serial.println("clock written"); | |
| vsynch = digitalRead(vsynch_p); | |
| href = digitalRead(href_p); | |
| pclock = digitalRead(pclock_p); | |
| if (vsynch == HIGH) return; | |
| if (href == LOW) return; | |
| if (!(lastPclock == HIGH && pclock == LOW)) { | |
| lastPclock = pclock; | |
| return; | |
| } else { | |
| lastPclock = pclock; | |
| } | |
| pixel = readByteFromDataInput(); | |
| char s[10]; | |
| sprintf(s, "%d ", pixel); | |
| Serial.println(s); | |
| if (control % 640 == 0) { | |
| Serial.println(""); | |
| } | |
| // just take one snapshot {{{ | |
| control++; | |
| // }}} | |
| if (control >= 307200) { | |
| Serial.println("finished"); | |
| } | |
| } | |
| byte readByteFromDataInput() { | |
| byte result = 0; | |
| for (int i = 0; i < 8; i++) { | |
| result = result << 1 | digitalRead(data_p[i]); | |
| } | |
| return result; | |
| } |
plz send me a video or working wile to my mail radhakrishna3579@gmail.com or send me in watsappp 9553793579
boss..i need to know how it takes snapshot and how it works?
@franciscospaeth
I would like to know how to view the snapshot taken?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank a lot bosssssssssssss