logo

如何使p4 p5针脚输出3v电压?

2019-05-22 16:12
B
yy

我自己写了程序p1p2是可以正常输出3.3 同样的方法p4p5只能输出49mv 请问是需要如何配置吗?现在我除了p4p5其他针脚都被占用了

2019-05-22 17:50
I
网红小智智 星瞳科技

请提供你的代码。

2019-05-22 18:58
B
yy

#斑点检测和uart传输

import sensor, image, time

from pyb import UART

import json

import sensor, image, time, network, usocket, sys

from pyb import Pin, Timer

#要想让颜色跟踪工作得很好,你最好是在一个非常非常,

#非常受控的环境,那里的照明是恒定的…

red_threshold = ( 16, 78, 17, 80, 6, 68)

SSID ='ktz' # Network SSID 无线网名字

KEY ='510964591' # Network key (must be 10 chars) 密码

HOST = '' # Use first available interface

PORT = 8080 # Arbitrary non-privileged port 端口

#你可能需要调整上面的设置来跟踪绿色的东西…

#在Framebuffer中选择一个区域来复制颜色设置。

sensor.reset() # 初始化相机传感器

sensor.set_pixformat(sensor.RGB565) # use RGB565.

sensor.set_framesize(sensor.QVGA) # use QQVGA for speed.

sensor.skip_frames(10) # 让新设置生效.

sensor.set_auto_whitebal(False) # 关掉白平衡.

clock = time.clock() # 跟踪fps.

ain1 = Pin('P4', Pin.OUT_PP)

ain2 = Pin('P5', Pin.OUT_PP)

ain1.low()

ain2.low()

uart = UART(3, 115200)

#uart = UART(3, 115200,timeout_char=10)

def find_max(blobs):

max_size=0

for blob in blobs:

if blob.pixels() > max_size:

max_blob=blob

max_size = blob.pixels()

return max_blob

while(True):

img = sensor.snapshot() # 拍照并返回图像。

blobs = img.find_blobs([red_threshold])

if blobs:

max_blob=find_max(blobs)#找到最大色块

print('sum :', len(blobs))

img.draw_rectangle(max_blob.rect())

img.draw_cross(max_blob.cx(), max_blob.cy())

output_str="[%d,%d]" % (max_blob.cx(),max_blob.cy()) #方式1

#output_str=json.dumps([max_blob.cx(),max_blob.cy()]) #方式2

#print('dangerous:',output_str)

ain1.low()

ain2.high()

uart.write(output_str+'\r\n')

else:

#print('gread')

ain1.high()

ain2.low()

请在这里粘贴代码
2019-05-23 12:56
I
网红小智智 星瞳科技

你应该直接测试IO的引脚。

from pyb import Pin
import time

pin4 = Pin('P4', Pin.OUT_PP, Pin.PULL_NONE)
pin5 = Pin('P5', Pin.OUT_PP, Pin.PULL_NONE)

while(True):
    pin4.value(0)
    pin5.value(0)
    time.sleep(1000)
    pin4.value(1)
    pin5.value(1)
    time.sleep(1000)
2019-05-23 16:01
B
yy

已经弄好了 谢谢