Seeing a Python code for the first time can seem a bit scary, especially if you have only programmed with blocks before. This tutorial explains the initial code in the LEGO SPIKE project briefly, as well as what it does.
- 20 Aug 2020
from spike import PrimeHub, LightMatrix, Button, StatusLight, ForceSensor, MotionSensor, Speaker, ColorSensor, App, DistanceSensor, Motor, MotorPair from spike.control import wait_for_seconds, wait_until, Timer hub = PrimeHub() hub.light_matrix.show_image('HAPPY')
The first two lines introduce commands that we can use below them. We will look at them in-depth later on.
The last line in the code is the command for displaying an image using the hub lights. In this case, the image is called "HAPPY" and it is a little smiley face :)