Going back to basic please.
I have read other members in the past struggle with this concept. eg Missing modules when installing on Windows 7 viewtopic.php?t=305.
Using the IDE, the code will flash the correctly the colours when connected and disconnected.
Code: Select all
# Main Module Example # # When your OpenMV Cam is disconnected from your computer it will either run the # main.py script on the SD card (if attached) or the main.py script on # your OpenMV Cam's internal flash drive. import time, pyb led = pyb.LED(3) # Red LED = 1, Green LED = 2, Blue LED = 3, IR LEDs = 4. usb = pyb.USB_VCP() # This is a serial port object that allows you to # communciate with your computer. While it is not open the code below runs. while(not usb.isconnected()): led = pyb.LED(1) led.on() time.sleep_ms(150) led.off() time.sleep_ms(100) led = pyb.LED(3) led.on() time.sleep_ms(150) led.off() time.sleep_ms(600) print("HELLO DISCONNECTED") led = pyb.LED(2) # Switch to using the green LED. while(usb.isconnected()): led.on() time.sleep_ms(150) led.off() time.sleep_ms(100) led.on() time.sleep_ms(150) led.off() time.sleep_ms(600) print("Hello CONNECTED")
A few times, you mentioned "Now on the next power up, the cam will run your code instead of the default". The USB cable is giving power to the cam - hence flash disconnected colours. Without using IDE, how can I make a connection the the cam?
Using python (Atom/Visual Studio Code) to connect to the CAM's com port
Code: Select all
# Windows OS import serial import time ser = serial.Serial('COM7', 115200, timeout=1, dsrdtr=False) ser.dtr = False ser.setDTR(False) print(ser.readline()) print(ser.isOpen) while True: line = ser.readline().strip() if line: print(line)
What am I missing? Have a not setup my python environment properly?
As you know, my first goal is to read the CAM's print() statement in python.
Thank you in advance.