-
Notifications
You must be signed in to change notification settings - Fork 145
Open
@gara-3004
Description
Hello,
I am trying to program an object tracking robot with lego mindstorms using the python language. However I am not able to communicate with the NXT cam.
#!/usr/bin/env pybricks-micropython from pybricks.hubs import EV3Brick from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor, InfraredSensor, UltrasonicSensor, GyroSensor) from pybricks.parameters import Port, Stop, Direction, Button, Color from pybricks.tools import wait, StopWatch, DataLog from pybricks.robotics import DriveBase from pybricks.media.ev3dev import SoundFile, ImageFile # This program requires LEGO EV3 MicroPython v2.0 or higher. # Click "Open user guide" on the EV3 extension tab for more information. # Create your objects here. ev3 = EV3Brick() # Write your program here. ev3.speaker.beep() import ev3dev2 from ev3dev2 import sensor from ev3dev2.sensor import lego from ev3dev2.sensor.lego import I2C # Set up the I2C port on the EV3 for communication with the NXTCam-v4 i2c_port = ev3dev2.get_current_i2c_bus() i2c_address = 0x01 # NXTCam-v4 I2C address i2c_sensor = lego.I2C(i2c_port, i2c_address) # Turn on the camera i2c_sensor.mode = lego.I2C.MODE_RAW # Set I2C mode to RAW i2c_sensor.write(0x01, 0x00) # Write 0x00 to register 0x01 to turn on the camera # Read data from the camera while True: i2c_sensor.write(0x00, 0x00) # Write 0x00 to register 0x00 to trigger a new frame data = i2c_sensor.read(8, lego.I2C.REPEAT) # Read 8 bytes of data from the camera # Process the data as needed
I tried this code but it keeps bringing up the error : no module named 'ev3dev2'
Metadata
Metadata
Assignees
Labels
No labels