Programming Qoopers & Q-scout with Python

Initiating

Importqmindfile and create an object robot

from qmind import Qmind
robot = Qmind('robot')

Movements

Set on-board motors’ movements (forward or backward)

  • Parameter 1: forward1, backward2, left3, right4
  • Parameter 2: speed range -90 to 90
robot.set_motor_type(1, 45)

Set on-board motors’ movements (clockwise or counterclockwise)

  • Parameter 1: left motor or right motor, range 1 to 2
  • Parameter 2: clockwise or counterclockwise, range 1 to 2
  • Parameter 3: speed range -90 to 90
robot.set_motor_direction(1, 2, -80)

Set angle for left or right servo motor

  • Parameter 1: port number. Qoopers range 1 to 8, Q-scout range 4
  • Parameter 2: servo motor insertion port, range 1 to 2
robot.motion_steering_engine(4, 1, 0, 0)

Set angle separately for left or right servo motor

  • Parameter 1: port number. Qoopers range 1 to 8, Q-scout range 4
  • Parameter 2: servo motor insertion port, range 1 to 2
  • Parameter 3: angle, range -180 to 180
  • Parameter 4: angle, range -180 to 180
robot.motion_steering_engine(4, 1, 90, 90)

Set external motor’s movement direction and speed

  • Parameter 1: port number, Qoopers range 1 to 8, Q-scout range 4
  • Parameter 2: external motor insertion port, range 1 to 2
  • Parameter 3: clockwise or counterclockwise, range 1 to 2
  • Parameter 4: speed range -90 to 90
robot.set_external_motor(4, 2, 0, 45)

Stop on-board motors’ movement

robot.set_motor_stop()

Set mini fan

  • Parameter 1: port number, Qoopers range 1 to 8, Q-scout range 4
  • Parameter 2:clockwise or counterclockwise, range 0 to 1
  • Parameter 3:speed range0 - 255
robot.set_mini_fan(4, 1, 45)

Lights

Set on-board lights’ color (RGB)

  • Parameter 1: both 0, left 1, right 2
  • Parameter 2: red, range 0 to 255
  • Parameter 3: green, range 0 to 255
  • Parameter 4: blue, range 0 to 255
robot.set_led(0, 220, 115, 220)

Set graphics for LED matrix panel

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
  • Parameter 2: graphic value
data = [
    [1,1,0,0,0,0,0,0,0,0,0,0,1,1],
    [0,0,1,1,0,0,0,0,0,0,1,1,0,0],
    [0,0,0,0,1,1,0,0,1,1,0,0,0,0],
    [0,0,0,0,0,0,1,1,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
]
robot.show_matrix(2, data)

Set graphics for RGB LED matrix panel

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
  • Parameter 2: graphic value
data = [
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0],
  [0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 0, 0],
  [0, 0, 4, 4, 4, 0, 0, 4, 0, 0, 0, 0],
  [0, 0, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
]
robot.gs_matrix_rgb_led4(0, data)

Set color for ultrasonic sensor’s lights (RGB)

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
  • Parameter 2: red, range 0 to 255
  • Parameter 3: green, range 0 to 255
  • Parameter 4: blue, range 0 to 255
robot.set_ultrasonic(0, 47, 144, 44)

Set RGBLED module(RGB)

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
  • Parameter 2: light,range0 - 40set all,1、2、3、4Corresponding to different lamp beads
  • Parameter 3: red, range 0 to 255
  • Parameter 4: green, range 0 to 255
  • Parameter 5: red, range 0 to 255
robot.set_led_color(2, 1, 155, 84, 20)

Set digital tube

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
  • Parameter 2: Numbers, whether integers or decimals, display up to 4 digits
robot.shows_digital1(2, 0)

Sound

Set buzzer frequency and lasting time

  • Parameter 1: frequency
  • Parameter 2: lasting time
robot.set_sound(262, 500)

Sensor

Get ultrasonic sensor value(cm)

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
robot.get_ultrasonic(2)

Get sound sensor value

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
robot.get_sound(2)

Get light sensor value

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
robot.get_light(2)

Get PIR motion sensor value

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
robot.get_infraredValue(2)

Get temperature and humidity sensor vlaue

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
robot.get_temperature(2) temperature
robot.get_humidity(2) humidity

Get rocker sensor value

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
  • Parameter 2: Axis, 0X axis, 1Y axis
robot.gs_sensing_rocker(2, 0)

Get potentiometer sensor value

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
robot.gs_sensing_spiral_potentiometer(2)

Get gas sensor value

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
robot.gs_sensing_gas(2)

Get flame sensor value

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
robot.gs_sensing_flame(2)

Get Slider sensor value

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
robot.gs_linePotentiometer(2)

Get 2-way temperature sensor value

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
  • Parameter 2: Probe, 1Probe1, 2Probe2
robot.get_temperature2(2,1)

Get gyro sensor value

  • Parameter 1: port number, Qoopers range 2 to 7, Q-scout range 1 to 3
  • Parameter 2: Axis, 0X axis, 1Y axis, 2Z axis
robot.getSensingGyroValue(2, 0)

results matching ""

    No results matching ""