下面两份代码,为何前者一供电,蓝灯就亮,而后者不行,我分别把代码都放入SD卡中测试了,难道不是一供电,OPENMV就运行SD卡中的代码么?还是别的问题?
# UART Control
#
# This example shows how to use the serial port on your OpenMV Cam. Attach pin
# P4 to the serial input of a serial LCD screen to see "Hello World!" printed
# on the serial LCD display.
import sensor, image, pyb
from pyb import UART
RED_LED_PIN = 1
BLUE_LED_PIN = 3
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
sensor.set_framesize(sensor.VGA) # or sensor.QQVGA (or others)
pyb.LED(RED_LED_PIN).off()
#pyb.LED(BLUE_LED_PIN).on()
print("You're on camera!")
# Always pass UART 3 for the UART number for your OpenMV Cam.
# The second argument is the UART baud rate. For a more advanced UART control
# example see the BLE-Shield driver.
uart = UART(3, 9600, timeout_char=1000)
while(True):
pyb.LED(3).on()
if uart.any():
a = uart.readline().decode()
print(a)
if a == "OK\r\n":
sensor.snapshot().save("example1.jpg")
uart.write("F")
pyb.LED(BLUE_LED_PIN).off()
print("Done! Reset the camera to see the saved image.")# UART Control
#
# This example shows how to use the serial port on your OpenMV Cam. Attach pin
# P4 to the serial input of a serial LCD screen to see "Hello World!" printed
# on the serial LCD display.
import sensor, image, pyb,time
from pyb import UART
RED_LED_PIN = 1
BLUE_LED_PIN = 3
# Always pass UART 3 for the UART number for your OpenMV Cam.
# The second argument is the UART baud rate. For a more advanced UART control
# example see the BLE-Shield driver.
uart = UART(3, 9600, timeout_char=1000)
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
sensor.set_framesize(sensor.VGA) # or sensor.QQVGA (or others)
sensor.skip_frames(time = 500) # Let new settings take affect.
pyb.LED(RED_LED_PIN).off()
sensor.skip_frames(time = 500) # Give the user time to get ready.
print("You're on camera!")
count = 0
while(True):
pyb.LED(3).on()
if uart.any():
a = uart.readline().decode()
if a == "OK":
count = count + 1
sensor.snapshot().save("%d.jpg"%(count)) # or "example.bmp" (or others)
print("Done! Reset the camera to see the saved image.")
uart.write("Finish")
print("Send Finish.")
time.sleep(100)
pyb.LED(BLUE_LED_PIN).off()
a = "\n";
else:
sensor.snapshot()
time.sleep(100)https://singtown.com/learn/50244/
按照步骤操作