Hi!
If I run the following program, there will be a 1 second lag in servo startup after receiving data.
So I would like to lack the limit on the fps output to the screen. please tell me. Thank you.
import time,pyb,sensor,image,micropython
from pyb import Pin,UART,Timer,Servo
from servo import Servos
from machine import I2C
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time=4000)
clock = time.clock()
####################################################################################################
MotorA=Pin('P1',Pin.OUT_PP,Pin.PULL_NONE)
MotorB=Pin('P2',Pin.OUT_PP,Pin.PULL_NONE)
i2c = I2C(sda=Pin('P5'), scl=Pin('P4'))
servo = Servos(i2c, address=0x40, freq=50, min_us=250, max_us=2800, degrees=180)
uart = UART(1, 115200, timeout=5)
####################################################################################################
#tim = Timer(1, freq=50)
#ch1 = tim.channel(1,Timer.PWM,pin=Pin("P7"),pulse_width_percent=1)
####################################################################################################
x=90
y=90
while(True):
img = sensor.snapshot()
print(clock.fps())
servo.position(7,x)
servo.position(6,y)
Data=0;
Data=uart.readchar()
if(Data!=0):
if(Data==1):
x+=1
elif(Data==2):
x-=1
elif(Data==3):
y+=1
elif(Data==4):
y-=1
elif(Data==5):
x=90
y=90
MotorA.value(True)
MotorB.value(False)
elif(Data==6):
x=90
y=90
MotorA.value(False)
MotorB.value(True)
else:
x=75
y=90
servo_1.py (1.16 KB)
pca9685_1.py (1.91 KB)
camera_main.py (1.91 KB)