Knowledge Base

Welcome to the Robotical knowledge base! These pages will help you get the most out of your Marty

Marty Images



This is an old revision of the document!


Marty's Disco Add-Ons: Getting Started

This page will help you get started with the disco add ons with Marty using the python library. Before we get started, make sure you have python installed and have set up your disco add ons.

Step 1

Import Martypy and establish connection to your Marty. Follow the code below to connect your Marty.

from martypy import Marty
my_marty = Marty("wifi", "192.168.0.42")  # Replace 192.168.0.42 by your Marty's IP

You should now be able to play with your disco add ons using the three functions below.

Step 2

The function disco_pattern allows you to set your disco add ons to a built-in pattern of lights. You will need to pass in your choice of pattern and specify the add on you would like to turn on, which is outlined below.

disco_pattern(pattern, add_on):

  • pattern: choose the pattern you would your add on to turn to. There are two options, so you must pass in the number 1 or 2.

  • add_on: This allows you to specify the specific add on on your marty that you would like to light up. Click Here to learn how to pass in your add ons.

Try this function using the code below to set all of your disco add ons to pattern 1.

my_marty.disco_pattern(1, my_marty.Disco.ALL)

Step 3

The function disco_color allows you to turn on and set your disco add ons to the color of your choice.

disco_color(color, add_on, region):

  • color: choose the color you would like your disco add ons to be. You can pass in either a hex code, RGB tuple, or a string calling one of the built in colors: white, red, blue, yellow, green, teal, pink, purple, and orange.

    You can use this color picker to find the hex code or RGB tuple of the color of your choice.

  • add_on: This allows you to specify the specific add on on your marty that you would like to light up. Click Here to learn how to pass in your add ons.

  • region: This allows you to specify the specific side of Marty’s eye, arm, or leg that you would like to light up. Revisit setting up your disco add ons for a refresher on these regions. You have the option to pass in 0, 1, or 2.

Try this function using the code below to set all of your disco add ons to teal.

my_marty.disco_color('teal', my_marty.Disco.ALL)

You can also get the same color by passing in a hex code or RGB tuple. See the code samples below on how you would pass the color teal as a hex code or RGB tuple, respectively.

my_marty.disco_color('#02d1bc', my_marty.Disco.ALL)
my_marty.disco_color((2, 209, 188), my_marty.Disco.ALL)

Step 4

The function disco_off allows you to turn off the disco add on of your choice. You can specify which specific add on you want to turn off, or turn off multiple at a time.

disco_off(add_on):

  • add_on: This allows you to specify the specific add on on your marty that you would like to turn off. Click Here to learn how to pass in your add ons.

Try this function using the code below to turn off all of your disco add ons.

my_marty.disco_off()


Party Marty!

Now we can use our disco functions to make Marty party! Follow the code below to light up Marty's disco add ons and make Marty dance.

from martypy import Marty
my_marty = Marty("wifi", "192.168.0.42")  # Replace 192.168.0.42 by your Marty's IP
my_marty.disco_color('blue', my_marty.Disco.FEET)
my_marty.disco_pattern(1, my_marty.Disco.EYES)
my_marty.disco_pattern(2, my_marty.Disco.ARMS)
my_marty.dance()
my_marty.disco_off()


Passing in Your Add Ons

When passing in your add ons, you have two options:

1. You can pass in a string of the name of the add on that you would like to call the function on. You can find the names of all your add ons by visiting the Scratch app and going to Configure –> ADD-ONS. Don't forget to disconnect the app after in order to connect with your Marty in python!

2. You can also pass in groupings of the add ons so you can call your chosen function on multiple add ons at a time! We have groupings for:

  1. my_marty.Disco.EYES
  2. my_marty.Disco.FEET
  3. my_marty.Disco.ARMS
  4. my_marty.Disco.ALL
   Pass in one the variables above in the **add_on** parameter of your chosen function when you would like to call a pair or all of the add ons.