Firstly, we can create sketch program to read incoming UART data on digital 10 and 11 pins using SoftwareSerial.
You can write this sketch:
#include <SoftwareSerial.h> SoftwareSerial mySerial(10, 11); // RX, TX void setup() { Serial.begin(9600); mySerial.begin(9600); } void loop() { if (mySerial.available() > 0) { Serial.write(mySerial.read()); } }
Save this program as Arduino_Serial.
Now we create a program for OpenMV. You can open OpenMV IDE and write the following complete codes:
from pyb import UART import time print('demo UART') uart = UART(3, baudrate=9600) counter = 50 while 1: uart.write(str(counter) + '\r\n') print('write uart:' + str(counter)) time.sleep(1500) counter += 1 if counter > 70: counter = 50
Save this program as uartdemo.py