The device library allows you to gather information about the devices connected to each of the hubs ports, as well as set the duty cycle of a device at a specific port.
MOTOR_MEDIUM_ID=48
MOTOR_LARGE_ID=49
COLOR_SENSOR_ID=61
DISTANCE_SENSOR_ID=62
FORCE_SENSOR_ID=63
Array<integer>
integerport
The port (ranging from A to F or 0 to 5) with the device to collect data from
1
2
3
4
5
6
7
use Libraries.Robots.Spike.Device
use Libraries.Robots.Spike.Port
use Libraries.Containers.Array
Device dv
Port port
Array<integer> raw_data_of_port_A
raw_data_of_port_A = dv:GetDataFromPort(port:A)
integer
integerport
The port (ranging from A to F or 0 to 5) with the device to get the ID of
1
2
3
4
5
use Libraries.Robots.Spike.Device
use Libraries.Robots.Spike.Port
Device dv
Port port
integer port_A_device_ID = dv:GetIDOfPort(port:A)
integer
integerport
The port (ranging from A to F or 0 to 5) with the device to get the duty cycle of
1
2
3
4
5
use Libraries.Robots.Spike.Device
use Libraries.Robots.Spike.Port
Device dv
Port port
integer port_A_duty_cycle = dv:GetDutyCycle(port:A)
None
integerport
The port (ranging from A to F or 0 to 5) with the device to set the duty cycle of
integerduty_cycle
The integer value from 0 to 10000 to set the duty cycle of the device to
1
2
3
4
5
use Libraries.Robots.Spike.Device
use Libraries.Robots.Spike.Port
Device dv
Port port
dv:SetDutyCycle(port:A, 5000)
boolean
integerport
The port (ranging from A to F or 0 to 5) with the device to check the ready state of
1
2
3
4
5
6
7
8
9
10
11
12
use Libraries.Robots.Spike.Device
use Libraries.Robots.Spike.Hub
use Libraries.Robots.Spike.LightMatrix
use Libraries.Robots.Spike.Port
Port port
Device dv
Hub hb
LightMatrix lights
repeat until IsPortReady(port:A)
hb:Sleep(1)
end
lights:Write("Device at Port A is READY!!!")