Openmv sending command to arduino

Hi, I am currently building a small robot car that detects the arrows on the wall using openmv. Im trying to make openmv to send a data to arduino uno so that when the camera detects the right or left arrow, it will turn according to the direction of the arrow. I did make the open mv cam to detect the arrows but I am still having problem sending the command to turn the car to the left or right according to the direction of the arrow using uart. I am new to sending commands and openmv and it is very confusing. It feels like the camera is not sending any data to the arduino at all because the car only rotates left and right. How should I write it so that the car turns left or right when it detects the arrow on the wall? (Dector is the openmv code i have come up with and robot car is the arduino ide code).
robot car.txt (4.05 KB)
detector.txt (1.51 KB)

Hi, it looks like your UART code is wrong…

import time, sensor, image
from pyb import UART
from image import SEARCH_EX, SEARCH_DS
ser = UART(3,115200,timeout_char=1000)
# Reset sensor

# Set sensor settings
# Max resolution for template matching with SEARCH_EX is QQVGA
# You can set windowing to reduce the search image.
#sensor.set_windowing(((640-80)//2, (480-60)//2, 80, 60))

# Load template.
# Template should be a small (eg. 32x32 pixels) grayscale image.
template = image.Image("/Right.pgm")
template = image.Image("/Left.pgm")
clock = time.clock()

# Run template matching
while (True):
    img = sensor.snapshot()

    # find_template(template, threshold, [roi, step, search])
    # ROI: The region of interest tuple (x, y, w, h).
    # Step: The loop step used (y+=step, x+=step) use a bigger step to make it faster.
    # Search is either image.SEARCH_EX for exhaustive search or image.SEARCH_DS for diamond search
    # Note1: ROI has to be smaller than the image and bigger than the template.
    # Note2: In diamond search, step and ROI are both ignored.
    r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
    l = img.find_template(template, 0.70, step=4, search=SEARCH_EX)
    if r:
    if l:

The above code should output binary 0x01 or 0x02 on the serial port when it sees an arrow. I noticed in your Arduino code you’re looking for a multibyte number. Change that to just look for the value 0x01 or 0x02.

Note, the previous code shouldn’t have run. It looked like there were compile issues in it.

I did change such way and now it says the it is out of memory. When I used pgm that is smaller in size than the one i previously used the point of interest is smaller than template. Im thinking compress() is the way to solve this but I don’t know how to use it. Can you help me out with this one please?

Hi, I need the PGM files you’re using. Also, why are you using templates exactly? Have you seen our AprilTag feature? It is much better for this type of activity. The tags aren’t exactly human readable but they are much easier for the robot to find. April Tags Tracking using the STM32F7 - YouTube

Anyway, if you’d like me to debug the script I need the pgm files. I’d watch the AprilTag video and just use the tags however.