Installation manual and usage instructions
Step 1 – connecting the changeover reed switch to the hub
1a – Use a Torx T6 screwdriver to remove the two screws on the back of the LEGO® SPIKE™ Prime ultrasonic sensor. Then remove the white part.
1b – Insert the brickobotik shield and screw the Torx T6 screws back in.
Step 2 – getting the brickobotik library
2a – Open Google Chrome Browser on your PC or Laptop.
2b – Connect the LEGO® SPIKE™ Prime to the USB port of your device.
2c – If the LEGO® Education SPIKE™ application is running on your device, please close it.
2d – Use the brickobotik library tool to download our library onto your hub.
3a – In the LEGO® Education SPIKE™ App use python for writing your program. You can now use all of the changeover reed switch’s features as documented in the API below.
This shield’s source API
intbrickobotik shield: changeover reed switch
In order to use the changeover reed switch you have to initialize it
first.
Example:
from brickobotik import ChangeoverReedSwitch
# initializing the changeover reed switch at port A
my_switch = ChangeoverReedSwitch(‚A‘)
int get_state()
Provides the current state of the magnetic switch.
Returns 1 if the last detected magnetic pole was a north pole and
0 if it was a south pole.
Example:
if my_switch.get_state() == 1:
print(‚State of switch: N‘)
else:
print(‚State of switch: S‘)
bool was_facing(orientation)
Returns True if orientation matches the orientation of the magnetic
field detected most recently, else False.
The parameter orientation has to be one of the values ‚NORTH‘, ‚N‘,
1, ‚SOUTH‘, ‚S‘, 0.
Example:
if my_switch.was_facing(‚SOUTH‘):
print(‚South pole detected recently!‘)
int wait_for_new_orientation()
The program waits until the switch changes its state and then
returns the new state in the same manner as get_state().
Example:
my_switch.wait_for_new_orientation()
# do something, for example, start a motor
my_switch.wait_for_new_orientation()
# do something, for example, stop a motor