logo

为什么没反应,传不到arduino数据,电脑显示不出来

2021-05-18 20:37
W
duyl
image
这是openmv的:
import sensor, image, time
import json
from image import SEARCH_EX, SEARCH_DS
from pyb import UART
uart = UART(3, 9600)

thresholds = [(22, 40, 2, 49, 3, 37), # generic_red_thresholds
              (31, 46, -20, 19, -31, -9)] # generic_blue_thresholds
# 不要超过16个颜色阈值
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False) # must be turned off for color tracking
sensor.set_auto_whitebal(False) # must be turned off for color tracking
clock = time.clock()
j = 1
clock.tick()
while(j<=6):
        img = sensor.snapshot().lens_corr(1.8)
        for blob in img.find_blobs(thresholds, pixels_threshold=200, area_threshold=200):
            if(blob.code() == 1):
                img = img.to_grayscale()
                for t1 in template1s:
                    template1 = image.Image(t1)
                r_1 = img.find_template(template1, 0.80, step=4, search=SEARCH_EX)
                for t2 in template2s:
                    template2 = image.Image(t2)
                r_2 = img.find_template(template2, 0.80, step=4, search=SEARCH_EX)
                for t3 in template3s:
                    template3 = image.Image(t3)
                r_3 = img.find_template(template3, 0.80, step=4, search=SEARCH_EX)
                if r_1:
                    uart.write('1')
                elif r_2:
                    uart.write('2')
                elif r_3:
                    uart.write('3')
                else:
                    uart.write('9')


这是arduino的代码:
#include<SoftwareSerial.h>
SoftwareSerial mySerial(14,15);
void setup()
{
  mySerial.begin(9600);
  Serial.begin(9600);
  pinMode(14,INPUT);
  pinMode(15,INPUT);
}

void loop()
{
  while(mySerial.available()>0)
  {
    char abc1 = (char)mySerial.read();
    Serial.print(abc1);     
  }
}![0_1621341426420_1 (1).png](正在上传 95%)
W
duyl
image
2021-05-19 18:21
I
网红小智智 星瞳科技

先用串口调试扩展板,或者示波器,看看OpenMV有没有数据发送出来。