logo

arduino给openmv发信息,openmv接不到

2019-08-14 19:02
T
s2va

这是arduino代码

#define PinA 2 //外部中断0

#define PinB 8 //编码器的OUTB信号连接到数字端口8

unsigned long time1 = 0; // 时间标记

long count = 0;

void setup()

{

pinMode(PinA, INPUT);

pinMode(PinB, INPUT);

attachInterrupt(0, Code, FALLING);//脉冲中断函数

Serial.begin (9600);

}

void loop()

{

Serial.println (count);

}

// 编码器计数中断子程序

void Code()

{

//为了不计入噪音干扰脉冲,

//当2次中断之间的时间大于5ms时,计一次有效计数

if ((millis() - time1) > 5)

{

//当编码器码盘的OUTA脉冲信号下跳沿每中断一次,

if ((digitalRead(PinA) == LOW) && (digitalRead(PinB) == HIGH))

{

count--;

}

else

{

count++;

}

}

time1 == millis();

}

这是openmv代码

uart = UART(3, 115200, timeout_char=1000)

while(True):

if uart.any():

a=uart.readline()

print(a)

#uart.write("Hello World!\r")

time.sleep(1000)

2019-08-15 12:02
I
网红小智智 星瞳科技

https://singtown.com/learn/50240/

先测试OpenMV的代码。