Approved content

The content below is provided by a partner.

artec-kk/pxt-artecrobo-kit 0.1.3 GitHub

ArtecRobo

Extension for ArtecRobo

Basic Usage

Use this to run an event when you press a Touch Sensor. You can specify A or B.

// Show a heart icon when you press the Touch Sensor:
artecrobo.onTouchSensorPressed(connectorTouchSensor.A, function () {
    basic.showIcon(IconNames.Heart)
})

Use this to check if the Touch Sensor is pressed. You can specify A or B.

// Press the Touch Sensor to show a heart icon:
if (artecrobo.isTouchSensorPressed(connectorTouchSensor.A)) {
    basic.showIcon(IconNames.Heart)
}

Use this to get the value of an Ultrasonic Sensor. You can specify P0, P1, or P2.

// Get the distance of an object to an Ultrasonic Sensor on P0 through serial:
serial.writeLine("" + (artecrobo.ultraSonicSensor(connectorDigitalSensor.P0)))

Use this to get the value of a Water Level Sensor. You can specify P0, P1, or P2.

// Get the value of a Water Level on P0 through serial:
serial.writeLine("" + (artecrobo.waterlevelSensor(connectorAnalogSensor.P0)))

Use this to get the value of a Temperature Sensor. You can specify P0, P1, or P2.

// Get the value of a Temperature Sensor on P0 through serial:
serial.writeLine("" + (artecrobo.temperatureSensor(connectorAnalogSensor.P0)))

Use this to get the value of an IR Photoreflector. You can specify P0, P1, or P2.

// Get the value of a IR Photoreflector on P0 through serial:
serial.writeLine("" + (artecrobo.irPhotoreflector(connectorAnalogSensor.P0)))

Use this to get the value of a Sound Sensor. You can specify P0, P1, or P2.

// Get the value of a Sound Sensor on P0 through serial:
serial.writeLine("" + (artecrobo.soundSensor(connectorAnalogSensor.P0)))

Use this to get the value of a Light Sensor. You can specify P0, P1, or P2.

// Get the value of a Light Sensor on P0 through serial:
serial.writeLine("" + (artecrobo.lightSensor(connectorAnalogSensor.P0)))

Use this to turn on the LED. You can specify P0, P1, or P2.

// Turn on an LED on P0:
artecrobo.turnOnLED(connectorDigitalSensor.P0)

Use this to turn off the LED. You can specify P0, P1, or P2.

// Turn off an LED on P0:
artecrobo.turnOffLED(connectorDigitalSensor.P0)

Use this to check whether an LED is on. You can specify P0, P1, or P2.

// Run a command when an LED on P0 is on:
if (artecrobo.isLEDOn(connectorDigitalSensor.P0)) {
}

Use this to play a set note on the micro:bit and an ArtecRobo Buzzer. You can specify P0, P1, or P2 as well as the note using the frequency.

// Play a sound at 262 Hz using the micro:bit and a Buzzer on P0:
artecrobo.turnOnSpeakerAndBuzzer(connectorDigitalSensor.P0, 262)

Use this to stop the micro:bit and ArtecRobo Buzzer. You can specify P0, P1, or P2.

// Stop playing the micro:bit and a Buzzer on P0:
artecrobo.turnOffSpeakerAndBuzzer(connectorDigitalSensor.P0)

Use this to play a note on an ArtecRobo Buzzer. You can specify P0, P1, or P2.

// Play a sound at 262 Hz using a Buzzer on P0:
artecrobo.turnOnBuzzer(connectorDigitalSensor.P0, 262)

Use this to stop an ArtecRobo Buzzer. You can specify P0, P1, or P2.

// Stop playing a Buzzer on P0:
artecrobo.turnOffBuzzer(connectorDigitalSensor.P0)

Use this to check whether an ArtecRobo Buzzer is playing. You can specify P0, P1, or P2.

// Show a heart icon if a Buzzer on P0 is playing:
if (artecrobo.isBuzzerplaying(connectorDigitalSensor.P0)) {
    basic.showIcon(IconNames.Heart)
}

Use this to set the speed of a DC Motor. You can specify M1 or M2 and a speed from 0 to 1023.

// Set M1 Dcmotor to max power(1023)
artecrobo.setSpeedDCMotor(connectorDCMotor.M1, 1023)

Use this to move a DC Motor in a set direction. You can specify M1 or M2 and a direction of Forward, Backward, Brake or Coast.

// Control M1 DC motor to Forward
artecrobo.moveDCMotor(connectorDCMotor.M1, DCmotion.Forward)

Use this to move a Servomotor to a set angle. You can specify P13, P14 or P15 and an angle from 0 to 180.

// Set a Servomotor on P13 to 90 degrees
artecrobo.moveServoMotorMax(connectorServoMotor.P13, 90)

Use this to move a Servomotor at a set speed. You can specify P13, P14 or P15, an angle from 0 to 180, and a speed from 1 to 20.

// Set a Servomotor on P13 to 90 degrees at speed 20:
artecrobo.moveServoMotor(connectorServoMotor.P13, 90, 20)

Use this to move multiple Servomotors at a set speed. You can specify P13, P14 or P15, an angle from 0 to 180, and a speed from 1 to 20.

// Set Servomotors on P13, P14, and P15 to 0, 90, and 180 degrees at speed 20:
artecrobo.AsyncMoveServoMotor(20, 0, 90, 180)

License

MIT

Supported targets

ArtecRobo=github:artec-kk/pxt-artecrobo-kit#v0.1.3