schooltore.blogg.se

Spike robotics
Spike robotics











spike robotics
  1. Spike robotics software#
  2. Spike robotics code#
  3. Spike robotics Bluetooth#

  • Change your code to explore another interaction with the sensor.
  • # Press the button slowly, it will work only once # Initialize the Force Sensor and a motor
  • Play the program and press on the button on the Force Sensor.
  • Let’s use the Force Sensor to control the motor. Example 3: Using the Force Sensor What You’ll NeedĬonnect a Force Sensor to Port B and a motor to Port C. n_to_position(90, 'clockwise', 100) ChallengeĬreate a short program to run 2 motors according to a beat, something like both motors in one direction, both in the other direction, one motor in opposite direction of the other, and more! # Run the motor to different positions, at different speeds
  • Change your code to make the motor stop in different positions.
  • # Place the motor in position “0,” aligning the markers Its position is indicated by the marker on the motor. Let’s bring the motor to the 0-degree position from whichever position it’s currently in. n_for_degrees(-360, 30) Run Single Motor to Position # Run the motor 360 degrees clockwise, at 30% speed
  • Modify your code to change the direction of the motor, using degrees of rotation.
  • Copy the code below to the Programming Canvas.
  • n_for_seconds(6.5, -30) Run Single Motor for Degrees # Rotate counterclockwise for 6.5 seconds at 30% speed
  • Modify your code to change the speed of the motor and the duration of its motion.
  • # Rotate clockwise for 2 seconds at 75% speed
  • Copy this code to the Programming Canvas.
  • Connect a motor to one of the Ports with a letter (e.g., Port C). Now we’ll connect a motor and turn it on.
  • Pick another sound to play, or use this program.Ĭreate a short countdown program, something like 3, 2, 1, BOOM! Example 2: Controlling the Motors What You’ll Need.
  • Copy the code below to the Programming Canvas.
  • You can also add some sounds to be played from your device.
  • Make sure you have only one line of code that starts with: from spike importĬhange the beat and the tone.
  • Then, copy the code below to the Programming Canvas.
  • If you have a program on the Programming Canvas, it is a good idea to delete it or start a new project to continue.
  • Your_hub.light_matrix.off() Playing Small Beeps and Time Your_hub.light_matrix.show_image('HEART') This will light up the happy face for 5 seconds, and then it will light up a heart for 5 seconds.
  • Or, copy in the code in the box bellow and paste it after the last line of your program.
  • This will light up the heart instead of the happy face on the Hub.
  • Either change the parameter 'HAPPY' to 'HEART' in the code you already have.
  • Change the image that’s displayed on the Light Matrix.
  • Your_hub.light_matrix.show_image('HAPPY') Can you figure out what this first program is all about?įrom ntrol import wait_for_seconds Lines with a "#" are comments they will not influence the actions. That is the space where you will write Python code.

    spike robotics

    Paste the code to the Programming Canvas.

    Spike robotics Bluetooth#

  • Connected it to your device via Bluetooth or USB.
  • Turned it on by pressing the Center Button.
  • Make sure that you’ve: installed the battery.
  • You're going to create some short programs for it. Print('LEGO') Example 1: Programming Simple Outputs What You’ll Need For example, there’s a difference between: x = 0 This makes it easier to code, once you’re familiar with the rules. Python is sensitive to capitalization, spaces, and indenting. Therefore, it isn’t executed as an action.

    spike robotics

    If you’re unsure of which libraries you should import, you can always import everything possible using: from spike import PrimeHub, LightMatrix, Button, StatusLight, ForceSensor, MotionSensor, Speaker, ColorSensor, App, DistanceSensor, Motor, MotorPairįrom ntrol import wait_for_seconds, wait_until, Timer Comments in PythonĮvery line starting with a “#” is considered a comment. py file, and should appear only once in the program. The imported libraries are located at the beginning of the.

    spike robotics

    Here are some of the libraries that you can import: When using SPIKE, you must always "include" the library that’s linked to the different hardware components (e.g., motors, Hub, sensors). In terms of programming, a library is basically all of the possible “ingredients” you can to use to create your “recipe.” When creating Python projects, you’ll often have to import a library of functions. There are only a few rules that you have to keep in mind when writing commands.

    Spike robotics software#

    It’s also an excellent language for programmers because it can be used for everything from web development to software development and scientific applications. It’s an excellent programming language for beginners because it’s concise and easy-to-read. Python is a very intuitive text-based coding language.

  • Example 4: Changing the Flow with Loops & Conditions.
  • You will find in the following parts of this “Getting Started” many examples of programs you can use as you explore the Python functionalities of SPIKE. Here is a place you can start to learn to code with Python.













    Spike robotics