Friday 26 September 2014

Arduino MEGA 2560 Board issues

Recently at work I found these on my desk:

ARDUCAM Shield, Arduino MEGA 2560 Rev3 (microprocessor), 2MP OV2640 (camera)



With these were the instructions "Make this work."

That's pretty much all I had to go on, so I made a start by looking on-line for ARDUCAM, thankfully I found a helpful tutorial on the ARDUCAM website, this made things a lot easier
and I managed to assemble the boards and "Make it work":


Now my challenge was to take a photograph with this camera and have it save the image to the SD card on the MEGA 2560. Arduino use there own IDE which you need to download in order to install the firmware into these boards. Fortunately for me they also provide a wide variety of example scripts written in C which you can upload to the board to test certain functions. (in the photo above I'm running the UTFT_Demo to see the screen working)

I have some history with C but I wouldn't say I was a professional, I know enough to recognise the language and fumble my way through it. Anyway I found a script which lets me take a photo and save it to the SD card, although like most things it's never that simple.

For reasons unknown to me at the time the device would let me take a photo but then freeze and not save anything to the SD card, so I decided to view the output of the serial port it was connected to. Turns out it couldn't recognise the SD card, so when I was taking a photo it was stuck in an endless loop trying to save the image.

The issue turned out to be SPI (Serial Peripheral Interface) on the MEGA 2560 board. The hardware SPI was doing what it was supposed to do but it was being overridden by a software SPI (Both called SPI in the code.....) The hardware SPI was needed for the TFT display to show the image, and the software SPI was needed to access the SD card. So I had to change the pin set for the software SPI in order to make it work. After I did that it started working perfectly fine.


I'm a total noob when it comes to hardware, but this has inspired me to learn more about how to program microprocessors, so I did what any noob would do, I bought a Raspberry Pi.

This site is enough to inspire anyone to get started with this stuff. My end goal with my new Pi is to control a robotic arm with a glove. Until then I think I'm going to attempt a retro game station. watch this space!





No comments:

Post a Comment