# ov7670
## 硬體環境
主機:Ubuntu 18.04
MCU硬體:arduino mini pro(atmega328)
## 系統工具
**工具鍊取得:**
```bash=
sudo apt-get install gcc-avr
sudo apt-get install avr-libc
sudo apt-get install libjpeg-dev
sudo apt-get install avrdude
```
## 硬體腳位接線

HREF也可能標示為HS
SDIOC也可能標示為SCL
SDIOD也可能標示為SDA
XCLK也可能標示為MCLK
## 軟體操作
目的:從PC端讀到由arduino擷取ov7670的圖像資料,之後透過uart傳輸到PC端並顯示出來。
**arduino端**
arduino的部份需要從[這裡](https://github.com/ComputerNerd/ov7670-no-ram-arduino-uno)下載,並且由於要燒錄的硬體是mini pro,所以必須在在makfile的writeflash裡面修改為
```bash=
$(AVRDUDE) -c $(AVRDUDE_PROGRAMMERID) \
-p $(PROGRAMMER_MCU) -P $(AVRDUDE_PORT) -b 57600 \
-U flash:w:$(HEXROMTRG)
```
之後用指令下載到arduino板子上
```bash=
sudo make writeflash
```
**PC端**
從[這裡](https://github.com/ComputerNerd/simpleFrameGrabber)下載PC端要用的程式,並且執行**build**編譯腳本,之後會產生**grab**這個執行檔,之後執行腳本**qqvga**就可在pPC上看到擷取的影像。
## 修正部份
**改進1:pc讀取的速度有點慢,目前懷疑是頻率問題。由於目前是smd的振盪器,無法確認實際的震盪頻率是多少,所以之後會找尋16mhz的版本試試看。**
**改進2:試過用nano(atmega168)運作,但程式會無法順利執行,懷疑是記憶體不足導致,可換成nano(atmega328)的版本執行看可否順利執行。**
---
參考資料:
1. [OV7670 Arduino Camera Sensor Module Framecapture Tutorial](https://www.instructables.com/OV7670-Arduino-Camera-Sensor-Module-Framecapture-T/)
2. [ov7670 datasheet](https://www.voti.nl/docs/OV7670.pdf)
3. [How to Use OV7670 Camera Module with Arduino](https://circuitdigest.com/microcontroller-projects/how-to-use-ov7670-camera-module-with-arduino)
4. [OV7670 Camera Module with Arduino: 10fps Video (Step-By-Step guide)](https://www.youtube.com/watch?v=Dp3RMb0e1eA&ab_channel=Indrek)
###### tags: `ov7670` `arduino` `Makefile`